Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install R packages that are not available in "R-essentials"?

I use an out-of-the-box Anaconda installation to work with Python. Now I have read that it is possible to also "include" the R world within this installation and to use the IR kernel within the Jupyter/Ipython notebook.

I found the command to install a number of famous R packages: conda install -c r r-essentials

My beginner's question:

How do I install R packages that are not included in the R-essential package? For example R packages that are available on CRAN. "pip" works only for PyPI Python packages, doesn't it?

like image 605
Frank Avatar asked Jan 10 '16 13:01

Frank


People also ask

How do I manually install an R package?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.

Why I Cannot install package in R?

Changing the configuration in R Studio to solve install packages issue. Go To Tools -> Global option -> Packages. Then uncheck the option “Use secure download method for HTTP”. For other RStudio issues refer to official Troubleshooting Guide here.


2 Answers

Now I have found the documentation:

This is the documentation that explains how to generate R packages that are only available in the CRAN repository: https://www.continuum.io/content/conda-data-science

Go to the section "Building a conda R package".

(Hint: As long as the R package is available under anaconda.org use this resource. See here: https://www.continuum.io/blog/developer/jupyter-and-conda-r)

alistaire's answer is another possibility to add R packages:

If you install packages from inside of R via the regular install.packages (from CRAN mirrors), or devtools::install_github (from GitHub), they work fine. @alistaire

How to do this: Open your (independent) R installation, then run the following command:

install.packages("png", "/home/user/anaconda3/lib/R/library") 

to add new package to the correct R library used by Jupyter, otherwise the package will be installed in /home/user/R/i686-pc-linux-gnu-library/3.2/png/libs mentioned in .libPaths() .

like image 136
Frank Avatar answered Sep 23 '22 14:09

Frank


To install other R Packages on Jupyter beyond R-essentials

install.packages('readr', repos='http://cran.us.r-project.org') 

One issue is that the specific repository is the US.R-Project (as below). I tried others and it did not work.

N.B. Replace readr with any desired package name to install.

like image 31
Yaw Avatar answered Sep 19 '22 14:09

Yaw