Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install R packages in Jupyter Notebook

I am trying to run R code in Jupyter and the R Kernel was added. Most of the time, packages can be installed successfully. However, some of the packages, such as RCurl and ggmap, would got error while installing.

Example:

install.packages("RCurl")

Warning message in install.packages("RCurl"): “installation of package ‘RCurl’ had non-zero exit status”Updating HTML index of packages in '.Library'

Making 'packages.html' ... done

What should I do?

like image 386
Xing Huang Avatar asked Feb 25 '17 17:02

Xing Huang


People also ask

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.

Is Jupyter Notebook compatible with R?

Jupyter supports over 40 programming languages, including Python, R, Julia, and Scala.


1 Answers

Try to specify CRAN as repository in your install.packages statement when installing RCurl and ggmap. For example:

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

This Stack Overflow post on installing R packages through Anaconda/Jupyter beyond those included in R essential provides more detail.

(Side note: I had encountered the same issue when trying to install R packages on computer clusters. This solution worked for me.)

like image 66
David C. Avatar answered Oct 08 '22 04:10

David C.