Skip to content

0. How to install?

Rasmus E. Benestad edited this page Nov 29, 2021 · 19 revisions

**IMPORTANT NOTICE ** ** The current version uses ncdf4 dependency. If you have problems installing ncdf4, you can still use ncdf dependency by installing esd from 'master-ncdf' branch (https://github.com/metno/esd/tree/master-ncdf). **

** There are some precompiled versions for Windows-users in this shared folder (in R-studio use 'Tools' in top menu bar and then select 'Install packages' after downloading the zip-file).**

From R-cran repository

esd cannot be installed directly from the R-cran repository, alternatively, there are several options listed below

From GitHub using R (copy the lines below into your R-window - this may take several minutes depending on the connection)

## Check if you need to get the devtools-package:
install.devtools <- ("devtools" %in% rownames(installed.packages()) == FALSE)

if (install.devtools) {
  print('Need to install the devtools package')
  ## You need online access.
    install.packages('devtools', dependencies = TRUE)
}

## Use the devtools-package for simple facilitation of installing.
library('devtools')
install_github('metno/esd')

A progress message is shown on the screen and a confirmation "DONE" is displayed when the installation is completed. Also, the library is loaded. This may take few minutes depending on the connection.

Screenshot

Downloading github repo metno/esd@master
Installing esd
'/usr/lib/R/bin/R' --vanilla CMD INSTALL  \
  '/tmp/RtmpjGyD1n/devtools239c70931bd9/metno-esd-ea15e85'  \
  --library='/home/user.name/R_libs' --install-tests 
* installing *source* package ‘esd’ ...
** R
** data
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (esd)
Reloading installed esd

From a Shell/Terminal

First, users need to install the related libraries to the package as

 > install.packages('ncdf4')
 > install.packages('zoo')

Note that some of the operating systems may need additional library for the 'ncdf4' package to be installed correctly. For instance, UBUNTU users need to install first the development kit for NetCDF (libnetcdf-dev).

Then, download the package from the github main page https://github.com/metno/esd using the 'Download ZIP' bottom on the right hand side of the page. Unzip the file, then install the package from the Linux/Mac shell as

$ R CMD INSTALL esd-master

From figshare,
First, download the 'esd' zipped file which corresponds to your operating system (Linux, Mac, or Windows) following this link esd-on-figshare. Then, download the zipped file from the esd repository on your local machine, and type the following command lines to begin the installation

on a linux shell

$ R CMD INSTALL esd.tar.zip

on R shell

> install.packages("esd.tar.gz")

A progress message is shown on the screen and a confirmation "DONE" is be displayed when the installation is completed.

Screenshot

* installing to library ‘/home/abdelkaderm/R_libs’
* installing *source* package ‘esd’ ...
** R
** data
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (esd)

Open an R session,

$ R

screenshot

R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
  Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
´´´

Load the library into R  

`> library(esd)`

> screenshot
```rout
Loading required package: ncdf4
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
    as.Date, as.Date.numeric

Check the package version by typing

> packageVersion("esd")

screenshot

[1] ‘0.5.1’

Add the esd package into the default list of packages using

options(defaultPackages=c(getOption("defaultPackages"),"esd"))

Compiling esd for Windows

If you have a Windows-machine, then it may require the additional app Rtools, especially if you want to install esd from a zipped archive.

If you have problems compiling a version of esd for Windows, it is possible to make a zip-version in Linux that can be installed in Windows. Here is the shell scrip (bash) esd4win.sh that does it for you

#/bin/bash
echo $1

R CMD INSTALL -l myR ~/R/esd
cd myR
zip -r esd_$1.zip esd
mv esd_$1.zip ..
cd ..
echo esd_$1.zip

Troubeshooting

You should make sure that you have the latest versions of R and Rstudio if you have problems installing esd.

If the installation is not complete an error or a warning message is displayed on the screen. This mainly due to some missing libraries in your operating system. The warning or error message contains useful information which clearly specifies the missing library or package. Install them independently and proceed the installation again as many times as needed before it is completed. An example is given below:

screenshot

* installing *source* package 'xml2' ...````
** package 'xml2' successfully unpacked and MD5 sums checked````
Package libxml-2.0 was not found in the pkg-config search path.````
Perhaps you should add the directory containing `libxml-2.0.pc'````
to the PKG_CONFIG_PATH environment variable````
No package 'libxml-2.0' found````
Package libxml-2.0 was not found in the pkg-config search path.````
Perhaps you should add the directory containing `libxml-2.0.pc'````
to the PKG_CONFIG_PATH environment variable````
No package 'libxml-2.0' found````
Using PKG_CFLAGS=````
Using PKG_LIBS=-lxml2````
------------------------- ANTICONF ERROR ---------------------------`
Configuration failed because libxml-2.0 was not found. Try installing:`
 * deb: libxml2-dev (Debian, Ubuntu, etc)`
 * rpm: libxml2-devel (Fedora, CentOS, RHEL)`
 * csw: libxml2_dev (Solaris)`
If libxml-2.0 is already installed, check that 'pkg-config' is in your`
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config`
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:`
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'`
--------------------------------------------------------------------`
ERROR: configuration failed for package 'xml2'`
* removing '/home/janeh/R/x86_64-pc-linux-gnu-library/3.4/xml2'`

then,

install.packages("xml2") install.packages("devtools",dependencies=T)

until no missing dependencies.