Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install.packages R on Ubuntu 12.04 downloads but does not install packages

I'm perplexed. I've done this process a dozen times and never had this issue.

I installed the latest version of R for Ubuntu

I enter R, no issues at all, gives me the latest version, and I can load native packages.

But When I try to install new packages, they download, but I get nothing. For example, if I install ggplot2:

> install.packages("ggplot2")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
also installing the dependencies ‘colorspace’, ‘stringr’, ‘RColorBrewer’, ‘dichromat’, ‘munsell’, ‘labeling’, ‘plyr’, ‘digest’, ‘gtable’, ‘reshape2’, ‘scales’, ‘proto’

trying URL 'http://rweb.quant.ku.edu/cran/src/contrib/colorspace_1.2-4.tar.gz'
Content type 'application/x-gzip' length 242791 bytes (237 Kb)
opened URL
==================================================
downloaded 237 Kb

trying URL 'http://rweb.quant.ku.edu/cran/src/contrib/stringr_0.6.2.tar.gz'
Content type 'application/x-gzip' length 20636 bytes (20 Kb)
opened URL
==================================================
downloaded 20 Kb

[snip ... ]

trying URL 'http://rweb.quant.ku.edu/cran/src/contrib/ggplot2_0.9.3.1.tar.gz'
Content type 'application/x-gzip' length 2330942 bytes (2.2 Mb)
opened URL
==================================================
downloaded 2.2 Mb


The downloaded source packages are in
        ‘/tmp/RtmpoPUAFL/downloaded_packages’
> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’

I've completely purged files a number of times, but not with any luck.

I'm logged in as root.

I feel like I'm missing something obvious? I don't know -- I've done this same thing a dozen times on Ubuntu, Mac, Windows, and Debian. Help?

like image 798
Erik Westlund Avatar asked Feb 17 '14 18:02

Erik Westlund


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.

How do I install downloaded packages in Ubuntu?

Once in the package location folder, you can use the following command format sudo apt install ./package_name. deb . For example, to install virtual-box, you can run. Also, the command above will install all the required software dependencies for the package that you are installing.

How do I install R downloaded packages?

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.

How manually install packages in Ubuntu?

Although, in the file Readme or INSTALL The necessary packages and how to install the program will be detailed in detail. I command them ./configure and make they are in charge of configuring and making the program package. The command make install install what was created and with ./ we run the program.


3 Answers

@jdharrison helped out. The problem was insufficient memory on the VPS I was running, so I added some swap as described here:

How do you add swap to an EC2 instance?

like image 115
Erik Westlund Avatar answered Nov 13 '22 20:11

Erik Westlund


Look at the last lines:

The downloaded source packages are in
    ‘/tmp/RtmpoPUAFL/downloaded_packages’

You have to go to the directory /tmp/RtmpoPUAFL/downloaded_packages (cd ...) and then install them manualy in the order that is pointed out above. So

R CMD INSTALL colorspace_1.2-4.tar.gz
R CMD INSTALL stringr_0.6.2.tar.gz
R CMD INSTALL ggplot2_0.9.3.1.tar.gz

Then trylibrary(ggplot2) now it should work

I have no idea why you have to do this sometimes... I anyone knows i am happy to learn it as well.

like image 32
Rentrop Avatar answered Nov 13 '22 20:11

Rentrop


If your server does not have enough ram, R can not install packages.

The solution is to either increase the physical ram, or increase the size of the swap file.

Create a 2 gig swap file

sudo fallocate -l 2G /swap.img
sudo mkswap /swap.img
sudo swapon /swap.img

You can see how much free swap is available with the swapon command

root@foo:# swapon -s
Filename                Type        Size    Used    Priority
/swap.img                               file        2097148 213388  -1
like image 43
spuder Avatar answered Nov 13 '22 18:11

spuder