[R] Customization options with .Renviron, R_LIBS, .Rprofile etc
Steve Lianoglou
mailinglist.honeypot at gmail.com
Tue Jul 21 22:29:51 CEST 2009
Hi,
On Jul 21, 2009, at 3:56 PM, ravi wrote:
> Hi,
> I am interested in customizing the installation of R. I have
> gone through the “R Installation and Administration” manual. But some
> of the stuff is not clear to me and I would like to get clarifications
> on the following points (for a Windows installation with
> R_HOME=C:\\R\\R-2.9.1 ) :
> 1. I understand that I need to create a
> file, .Renviron with the following path : R_HOME\\etc\\.Renviron where
> a number of environmental variables can be set. I would first like to
> know if the file to be created is Renviron or .Renviron.
If the files in the R install on my mac would provide a hint, I'm
guessing it should be Renviron (no period).
> Both versions
> are mentioned in the manual. By the way, many functions in R start
> with
> a period.
Really? Which functions have you found that you want to use start with
a period?
Anyway, I'm guessing these are functions are ones that probably
shouldn't be used by "an end user."
> Is there any special significance to a name (file, function
> etc) if it starts with a period?
Files that start with a period are typically reserved for "hidden
files", at least on unix/linux machines ... not sure about windows
machines.
> 2. I want to have two different
> libraries – one for the packages that follow with the R installation
> and a second one for any additional packages that I add afterwards. By
> doing this, I hope to avoid repeating the installation of these
> packages
> once again after an update of R.
I wouldn't recommend doing this in this in this scenario. "Minor"
upgrades in R (ie. 2.9.0 to 2.9.1) don't really require you to
reinstall your packages, but an upgrade from 2.8 to 2.9 should also
involve upgrading all packages you have installed.
In either event, you can install a package in a particular directory
by setting the target directory path in the "lib" argument to the
"install.packages" function.
> I understand that I can set the paths
> to these libraries with the environmental variables R_LIBS or
> R_LIBS_USER in the .Renviron file. But I am not entirely sure about
> the
> difference between these two environmental variables. It is mentioned
> in the manual that multiple paths (for different libraries) can be
> specified. Does this mean that I can set the paths with any of these
> environmental variables? Or, should I set R_LIBS=R_HOME\\library and
> R_LIBS_USER to my private library? Does this also mean that any
> package that
> I add with the install.packages() function will then end up in the
> private library?
> 3. If I want to start R with a certain set of
> packages loaded on startup, I understand that I need to create a file
> .Rprofile with the path R_HOME\\etc\\.Rprofile. Again, should it be
> .Rprofile or Rprofile (or, is it Rprofile.site which I see is already
> present in my R installation)?
It should be .Rprofile -- probably you want to put this file in your
home directory.
> Is the following syntax OK for
> specifying the environmental variable
> R_DEFAULT_PACKAGES = {“base”, “datasets”,”utils”,”ggplot2”,“lattice”}
> How can I add, for example, ggplot2 and lattice to the list of
> default packages that R normally starts with?
A simple way is to just add the appropriate "library" calls at the
start of your ~/.Rprofile file
> 4.
> If I add a .Renviron file to my working directory, will it override
> that in R_HOME? Or, is it the other way around? Can I add a .Rprofile
> file as well to the working directory where I can specify the
> R_DEFAULT_PACKAGES a little differently?
Have a look at ?Startup and I don't think R loads an .Rprofile file in
your current working directory (at least, it's not doing it for me).
-steve
--
Steve Lianoglou
Graduate Student: Physiology, Biophysics and Systems Biology
Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list