User Tools

Site Tools


r_antsr_usage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
r_antsr_usage [2016/03/23 21:06]
mgstauff
r_antsr_usage [2017/04/10 20:28] (current)
mgstauff [Local/User Package Installation]
Line 1: Line 1:
 ===== R ===== ===== R =====
 +
 +==== Local/User Package Installation ====
 +
 +As of R 3.2, R should create a default location for local libraries (i.e. that you install on your own). Check using the ''.libPaths()'' command. It should be something like ''/home/<username>/R/x86_64-pc-linux-gnu-library/3.2''. If you want to install packages somewhere other than the default, you can change this using R_LIBS_USER.
 +
 +R_LIBS_USER will by default be the first line shown by ''.libPaths()''. This will change the default installation directory. Also, libraries will be loaded from $R_LIBS_USER first. If not found, it will proceed down the list from .libPaths()
 +
 +**HOWEVER** if you define R_LIBS, it will be used before R_LIBS_USER in search and installation paths. This can be confusing. For installation, it's safest to always specify the installation path directly in the install command.
 +
 +Some documentation here:
 +https://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html
 +
 +
 +==== Managing Packages ====
 +
 +Managing packages:
 +
 +R can read packages from any of the locations listed in .libPaths(). This typically contains both a system directory (under /share/apps) and a user directory (under /home). Both of these can vary over time; the system packages may be upgraded, added, or removed. Further, individual users might run the same code with different local versions of the same library.
 +
 +To avoid this, use the packrat package (https://rstudio.github.io/packrat/). This creates a private repository of packages specific to a particular project. This allows other users (or yourself at a later date) to reproduce results with a common set of packages.
 +
 +Packages that don't affect the outcome of studies, like roxygen2 or ggplot2, can be defined as "external packages", and loaded from another source. This is useful to avoid keeping multiple copies of such packages for multiple projects.
  
 ==== ''unsupported URL scheme'' - package installation issue ==== ==== ''unsupported URL scheme'' - package installation issue ====
Line 22: Line 44:
 ==== Installing from R ==== ==== Installing from R ====
  
-(Thanks to Phil Cook!)+(Thanks to Phil Cook! Updated 4/2017)
  
 Setup in your ''.bash_profile'' file: Setup in your ''.bash_profile'' file:
  
-  export PATH=/share/apps/R/R-3.2.3/:$PATH  #note that this may already be defined in .bash_profile, check first+  export PATH=/share/apps/R/<version>/:$PATH  #note that this may already be defined in .bash_profile, check first
      
-  export R_LIBS=/home/pcook/R/x86_64-unknown-linux-gnu-library/3.2 
- 
 Then on chead Then on chead
  
Line 36: Line 56:
   > install.packages("devtools", repos="http://cran.cnr.berkeley.edu/")   > install.packages("devtools", repos="http://cran.cnr.berkeley.edu/")
   > library(devtools)   > library(devtools)
-  > install_github("stnava/cmaker") 
   > install_github("stnava/ITKR")   > install_github("stnava/ITKR")
 +  > install_github("stnava/ANTsRCore")
   > install_github("stnava/ANTsR")   > install_github("stnava/ANTsR")
 +  
 +
 +
r_antsr_usage.1458767169.txt.gz ยท Last modified: 2016/03/23 21:06 by mgstauff