Difference between revisions of "Installing R"
(→Creating a global R profile) |
(→Creating a global R profile: cp Rprofile) |
||
Line 97: | Line 97: | ||
;Note, the Rprofile.site file does not seem to be copied to the latest current installation of R (2.3.x). | ;Note, the Rprofile.site file does not seem to be copied to the latest current installation of R (2.3.x). | ||
+ | locate Rprofile.site | ||
+ | cp /Library/Frameworks/R.framework/Versions/2.7/Resources/etc/Rprofile.site /Library/Frameworks/R.framework/Versions/2.8/Resources/etc/Rprofile.site | ||
===SVG graphics=== | ===SVG graphics=== |
Revision as of 22:23, 22 December 2008
Contents
R programming language
R is a powerful statistical programming language, an implementation of the S programming language, with semantics derived from Scheme (see R programming language for details).
R on OS X
Install the R dmg format from a local CRAN mirror, e.g. Auckland statistics mirror.
Installation details
On OS X, R installs in the path;
/Library/Frameworks/R.framework /Library/Receipts/ # (R-*.pkg receipts) |
The binary to run R is located at /usr/bin/R, it is now a symbolic link pointing to;
lrwxr-xr-x 1 root wheel 47 Jul 27 16:45 /usr/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R symbolic link created by; ln -s /Library/Frameworks/R.framework/Resources/bin/R /usr/bin/R |
It looks like in previous versions this was a binary not a pointer to a version specific binary.
The directory structure is;
# ls -la /Library/Frameworks/R.framework/ drwxrwxr-x 8 root admin 272 Jul 27 16:44 . drwxrwxr-x 6 root admin 204 Aug 23 2005 .. -rw-rw-r-- 1 root admin 6148 Aug 23 2005 .DS_Store lrwxr-xr-x 1 root admin 24 Jul 27 16:44 Headers -> Versions/Current/Headers lrwxr-xr-x 1 root admin 31 Jul 27 16:44 PrivateHeaders -> Versions/Current/PrivateHeaders lrwxr-xr-x 1 root admin 18 Jul 27 16:44 R -> Versions/Current/R lrwxr-xr-x 1 root admin 26 Jul 27 16:44 Resources -> Versions/Current/Resources drwxrwxr-x 9 root admin 306 Jul 27 16:44 Versions |
The symbolic link for R points (R -> Versions/Current/R) to the current release, version which is located at /Library/Frameworks/R.framework/Versions/Current.
The symbolic link Resources (R -> Versions/Current/R) points to the version release directory structure including the currently installed packages in the library subdirectory. You can identify all installed versions in the Versions subdirectory;
#ls -la /Library/Frameworks/R.framework/Versions/ drwxrwxr-x 9 root admin 306 Jul 27 16:44 . drwxrwxr-x 8 root admin 272 Jul 27 16:44 .. -rw-rw-r-- 1 root admin 6148 Oct 17 2005 .DS_Store lrwxr-xr-x 1 root admin 5 Aug 16 2005 2.1 -> 2.1.1 lrwxr-xr-x 1 root admin 5 Aug 16 2005 2.1.0 -> 2.1.1 drwxrwxr-x 4 root admin 136 Dec 14 2005 2.1.1 drwxrwxr-x 4 root admin 136 Jul 27 16:44 2.2 drwxrwxr-x 6 root admin 204 Jul 27 16:44 2.3 lrwxr-xr-x 1 root admin 3 Jul 27 16:44 Current -> 2.3 |
Running different versions of R
If you want to change the pointer to the version of R that you wish to run, all that is required is to change the Current pointer above, e.g.
sudo -s [enter password] cd /Library/Frameworks/R.framework/Versions rm Current ln -s 2.2 Current |
To point to the current release again;
cd /Library/Frameworks/R.framework/Versions rm Current ln -s 2.3 Current |
- Note, sometimes there seems to be something peculiar happening where the binary is not visible, re-installation of R fixes this without effecting additional packages already loaded.
Tcl/Tk Issues
The X11 graphics display will not work until X11 is started, and the environmental variable Sys.putenv("DISPLAY"=":0") is set.
Creating a global R profile
The DISPLAY variable along with other customizations can be set using a global R profile. To do this create a file called Rprofile.site in R_HOME$/etc. See help(RProfile.site)
for details. the file is expected to be located in;
R_HOME/etc/Rprofile.site
where the environment variable is set to;
> Sys.getenv("R_HOME") R_HOME "/Library/Frameworks/R.framework/Resources" |
The Rprofile.site file should be a text file containing a global .First function, e.g.
.First <- function() { Sys.putenv("DISPLAY"=":0") Sys.putenv("http_proxy"="http://proxy.hort.net.nz:8080") options(device="X11") } |
- Note, the Rprofile.site file does not seem to be copied to the latest current installation of R (2.3.x).
locate Rprofile.site cp /Library/Frameworks/R.framework/Versions/2.7/Resources/etc/Rprofile.site /Library/Frameworks/R.framework/Versions/2.8/Resources/etc/Rprofile.site
SVG graphics
The There are libraries that creates svg graphics aswell as native support now in R ( see help(svg) ).