[R] Loading R scripts stored behind htaccess

Gaj Stan (BIGCAT) stan.gaj at maastrichtuniversity.nl
Fri Jul 13 12:13:48 CEST 2012


Within my department I would like to share the latest version(s) of my R scripts to my colleagues using subversion. This repository is password protected (WebDAV) as it should not be accessed by external persons. 
In the majority of my scripts I load scripts using the source() function, but this will now return a ''401 Authorization Required'  error.

I've been browsing through the RCurl documentation, since this seems to be the package that will allow me to do this and use the following line of code to download the script content and load a single script:

  x <- getURL("http://www.example.com/script.R", userpwd="key:secret") 
  write(x, "script.R")

I have two direct questions related to this:
- Can this be done in an easier/neater way? In some cases there are a considerable amount of scripts that need to be downloaded (up to 7 or so). If not, then this will be converted to a small function. Ideally the scripts should be loaded immediately, without any download steps.
- I'm not really in favor of storing user names and passwords in scripts. Does anyone know of a way where R asks the user which login credentials to use, stores this in an (encrypted) variable and then uses this to access the website?


  -- Stan

More information about the R-help mailing list