Sourcing R script over HTTPS

前端 未结 6 1671
盖世英雄少女心
盖世英雄少女心 2020-11-30 05:52

Is there some way to source an R script from the web?

e.g. source(\'http://github.com/project/R/file.r\')

Reason: I currently have a project tha

6条回答
  •  误落风尘
    2020-11-30 06:11

    Windows:

    If Internet Explorer is configured to access the web using your organization's proxy, you can direct R to use these IE settings instead of the default R settings. This change can be made once by the following steps:

    1. Save your work and close all R sessions you may have open.

    2. Edit the following file. (Note: Your exact path will differ based on your R installation)

      C:\Program Files\R\R-2.15.2\etc\Rprofile.site

    Open this "Rprofile.site" file in Notepad and add the following line on a new line at the end of the file:

    utils::setInternet2(TRUE)
    

    You may now open a new R session and retry your "source" command.

    Linux alikes:

    Use G. Grothendieck's suggestion. At the command prompt within R type:

    source(pipe(paste("wget -O -", "https://github.com/enter/your/url/here.r")))
    

    You may get an error saying:

    cannot verify certificate - - - - Self-signed certificate encountered.
    

    At this point it is up to you to decide whether you trust the person issuing the self-signed certificate and proceed or to stop.

    If you decide to proceed, you can connect insecurely as follows:

    source(pipe(paste("wget -O -", "https://github.com/enter/your/url.r", "--no-check-certificate")))
    

    For more details, see the following:

    See section 2.19

    • CRAN R Documentation 2.19
    • wget documentation section 2.8 for "no-check-certificate"

    Similar questions here:

    • Stackoverflow setInternet2 discussion
    • Stackoverflow Proxy configuration discussion

提交回复
热议问题