Difference between revisions of "Installing R"

From Organic Design wiki
m
m (Creating a global R profile)
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Nutrigenomics]]
+
[[Category:Installation|R]][[Category:Limma]][[Category:Nutrigenomics]][[Category:R]]
[[Category:R]]
 
[[Category:Limma]]
 
  
=R programming language=
+
== R programming language ==
 
R is a powerful statistical programming language, an implementation of the [[Wikipedia:S programming language|S programming language]], with semantics derived from [[Wikipedia:Scheme|Scheme]] (''see [[Wikipedia:R programming language|R programming language]] for details'').
 
R is a powerful statistical programming language, an implementation of the [[Wikipedia:S programming language|S programming language]], with semantics derived from [[Wikipedia:Scheme|Scheme]] (''see [[Wikipedia:R programming language|R programming language]] for details'').
  
==R on OS X==
+
== R on OS X ==
 
Install the R [[Wikipedia:.dmg|dmg format]] from a local [[Wikipedia:CRAN|CRAN]] mirror, e.g. [http://cran.stat.auckland.ac.nz Auckland statistics mirror].
 
Install the R [[Wikipedia:.dmg|dmg format]] from a local [[Wikipedia:CRAN|CRAN]] mirror, e.g. [http://cran.stat.auckland.ac.nz Auckland statistics mirror].
  
===Installation details===
+
=== Installation details ===
 
On OS X, R installs in the path;
 
On OS X, R installs in the path;
 
<table class=document-code><tr><td>
 
<table class=document-code><tr><td>
 
 
  /Library/Frameworks/R.framework
 
  /Library/Frameworks/R.framework
 
  /Library/Receipts/ # ''(R-*.pkg receipts)
 
  /Library/Receipts/ # ''(R-*.pkg receipts)
 
</table>
 
</table>
 +
The binary to run R is located at ''/usr/bin/R'', it is now a symbolic link pointing to;
 +
<table class=document-code><tr><td>
 +
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
 +
</table>
 +
It looks like in previous versions this was a binary not a pointer to a version specific binary.
 +
 
The directory structure is;
 
The directory structure is;
 
<table class=document-code><tr><td>
 
<table class=document-code><tr><td>
Line 47: Line 52:
 
</table>
 
</table>
  
===Running different versions of R===
+
==== 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 ''Resources'' pointer, e.g.
+
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.
  
 
<table class=document-code><tr><td>
 
<table class=document-code><tr><td>
 
  sudo -s  
 
  sudo -s  
 
  [enter password]  
 
  [enter password]  
  rm -f /Library/Frameworks/R.framework/Resources
+
  cd /Library/Frameworks/R.framework/Versions
  cd /Library/Frameworks/R.framework/
+
  rm Current
  ln -s Versions/2.2/Resources Resources
+
  ln -s 2.2 Current
 
</table>
 
</table>
  
 
To point to the current release again;
 
To point to the current release again;
 
<table class=document-code><tr><td>
 
<table class=document-code><tr><td>
  rm -f /Library/Frameworks/R.framework/Resources
+
  cd /Library/Frameworks/R.framework/Versions
  cd /Library/Frameworks/R.framework/
+
  rm Current
  ln -s Versions/Current/Resources Resources
+
  ln -s 2.3 Current
 
</table>
 
</table>
 +
 +
;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 [http://en.wikipedia.org/wiki/X_Window_System X11] is started, and the environmental variable [http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#TclTk-issues 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 [http://cran.r-project.org/doc/FAQ/R-FAQ.html#Others Rprofile.site] in R_HOME$/etc. See <code>help(RProfile.site)</code> for details. the file is expected to be located in;
 +
 +
R_HOME/etc/Rprofile.site
 +
 +
where the environment variable is set to;
 +
<table class=document-code><tr><td>
 +
> Sys.getenv("R_HOME")
 +
                                    R_HOME
 +
"/Library/Frameworks/R.framework/Resources"
 +
</table>
 +
 +
The ''Rprofile.site'' file should be a text file containing a global ''.First'' function, e.g.
 +
<table class=document-code><tr><td>
 +
.First <- function() {
 +
  Sys.putenv("DISPLAY"=":0")
 +
  Sys.putenv("http_proxy"="http://proxy.hort.net.nz:8080")
 +
  options(device="X11")
 +
}
 +
</table>
 +
 +
;Note, the Rprofile.site file does not seem to be copied over for a newer installation of R.
 +
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) ).
 +
* [http://cran.stat.auckland.ac.nz/web/packages/RSvgDevice/index.html RSvgDevice]
 +
* [http://cran.stat.auckland.ac.nz/web/packages/RSVGTipsDevice/index.html RSVGTipsDevice]
 +
 +
==See also==
 +
*http://search.r-project.org/
 +
*[http://dir.gmane.org/gmane.science.biology.informatics.conductor Searching Biocondcutor]

Latest revision as of 22:24, 22 December 2008


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 over for a newer installation of R.
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) ).

See also