Monday 20 April 2015

r updates and packages

The package 'installr' makes it simple to upgrade R to a new version with the following command

library(installr) 


To install the latest version of R:

install.R()


To install the associated program used with R:

The below lists only some of the examples

install.ImageMagick()  
install.Rtools() 
install.MikTex()  
install.pandoc()   


To update installed R to the latest version:

updateR()


To install packages, you can set the source by specifying 'repos=' and specify the path to the library by setting 'lib=' (in Windows, .libPaths() can be used to set up a default path to the library folder at the beginning for the session)

install.packages("dplyr", repos="http://cran.csiro.au/", lib="C:/Users/Documents/MyLibrary")

   
If you are installing packages from the local directory, provide path and name of the file to be installed.

          install.packages("[path to the directory]/[name of file (e.g. ada_2.0-5.zip)]", repos=NULL,  type="source")
 
 
The list of all repos url's can be found at http://cran.r-project.org/mirrors.html


To list all the packages installed at a specified library path

installed.packages(lib.loc="path")

  
To check if any packages in the library are old,   
  

old.packages()

    
To check for new packages,   
  
new.packages()
 

To update existing packages to the latest version  


update.packages()

 


For those work places using Windows where firewall prevents downloading of the packages, you may need to download zip files from the source and install them locally by using the tool bar options in the R console.  

   




To check what packages are available:

(.packages())


To check all available packages:

(.packages(all.available=TRUE))

alternatively,

library()

 


To check for all packages in the repository:
available.packages()


To remove packages:

remove.packages("name_of_package","library_path")


  
  
To download the package in its compressed form (e.g. *.tar.gz):

download.packages("name_of_package",destdir="destination_path")








  
  
To download multiple packages at once,

download.packages(c("name_of_package1","name_of_package2","name_of_package3"), destdir="destination_path")

   
  
A contributed package called 'tools' provides useful function to check for dependencies of the installed packages:

library(tools)   
inst_pack<-installed.packages()   
package.dependencies(inst_pack)
     










No comments:

Post a Comment