User Tools

Site Tools


wiki:installpkage

Installing a new package

Start R as superuser to have rights to install new packages:

sudo R 

To verify which packages you have installed and where the library directories are type:

library()

You will see the list of your available library as follows:

class                   Functions for Classification
colorspace              Color Space Manipulation
gdata                   Various R programming tools for data
                        manipulation
gtools                  Various R programming tools
maptools                Tools for reading and handling spatial objects
MASS                    Main Package of Venables and Ripleys MASS
mda                     Mixture and flexible discriminant analysis
nnet                    Feed-forward Neural Networks and Multinomial
                        Log-Linear Models
randomForest            Breiman and Cutlers random forests for
                        classification and regression
rgdal                   Bindings for the Geospatial Data Abstraction
                        Library
sp                      classes and methods for spatial data
spatial                 Functions for Kriging and Point Pattern
                        Analysis
vcd                     Visualizing Categorical Data
xtable                  Export tables to LaTeX or HTML
Packages in library '/usr/lib/R/site-library':
base                    The R Base Package
boot                    Bootstrap R (S-Plus) Functions (Canty)
class                   Functions for Classification
grid                    The Grid Graphics Package
KernSmooth              Functions for kernel smoothing for Wand & Jones
                        (1995)
lattice                 Lattice Graphics
MASS                    Main Package of Venables and Ripleys MASS
Matrix                  Sparse and Dense Matrix Classes and Methods
methods                 Formal Methods and Classes
mgcv                    GAMs with GCV/AIC/REML smoothness estimation
                        and GAMMs by PQL
nlme                    Linear and Nonlinear Mixed Effects Models
nnet                    Feed-forward Neural Networks and Multinomial
                        Log-Linear Models
rpart                   Recursive Partitioning
spatial                 Functions for Kriging and Point Pattern
                        Analysis
splines                 Regression Spline Functions and Classes
stats                   The R Stats Package
stats4                  Statistical Functions using S4 Classes
 survival                Survival analysis, including penalised
                        likelihood.
tcltk                   Tcl/Tk Interface
tools                   Tools for Package Development
utils                   The R Utils Package
(END)
To exit the library mode list, type q
q
libPaths()
update.packages

library(splines)

>

> this means that the splines package is now loaded

library(spgrass6)

If you see

Error in library(spgrass6) : there is no package called 'spgrass6'

This means that spgrass6 is not loaded and ypou need to download it and installing it

So you need to install the package: install.packages(pkgs=“PACKAGE NAME”, lib= “library directories where to install the packages”, dependencies=TRUE)

To know more: ? install.packages

  install.packages(pkgs="randomForest", lib= "/usr/lib/R/site-library", dependencies=TRUE)
 

You will see:

install.packages(pkgs="spgrass6",lib= "/usr/lib/R/site-library"),dependencies=TRUE)
install.packages(pkgs="rgdal",lib= "/usr/lib/R/site-library",dependencies=TRUE)
 --- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
also installing the dependencies ‘sp’, ‘rgdal’, ‘XML’
trying URL 'http://cran.ch.r-project.org/src/contrib/sp_0.9-36.tar.gz'
Content type 'application/x-gzip' length 412739 bytes (403 Kb)
opened URL
  ===============================================
downloaded 403 Kb
trying URL 'http://cran.ch.r-project.org/src/contrib/rgdal_0.6-8.tar.gz'
Content type 'application/x-gzip' length 1389205 bytes (1.3 Mb)
opened URL
==================================================
downloaded 1.3 Mb
trying URL 'http://cran.ch.r-project.org/src/contrib/XML_2.3-0.tar.gz'
Content type 'application/x-gzip' length 659797 bytes (644 Kb)
opened URL
==================================================
downloaded 644 Kb

Check :

available.packages()

Install a new package from source

From the bash terminal browse https://cran.r-project.org/src/contrib/ repository and find the pakage yopu like to wownload and it's web link

  wget https://cran.r-project.org/src/contrib/dismo_1.0-15.tar.gz
  sudo R CMD INSTALL dismo_1.0-15.tar.gz

Done

wiki/installpkage.txt · Last modified: 2017/12/05 22:53 (external edit)