2

I am trying to install packages in R, but after downloading, loading the package library will not work -- upon running require("<package_name>") or library("<package_name>") I get the error:

Error in library("package_name") : there is no package called ‘package_name’

I am running R 3.0.2 on Ubuntu 14.04.1, which is installed in a vagrant virtual machine running inside of os x mavericks.

I have tried re-installing everything (R, Ubuntu, sudo apt-get --reinstall install r-base-dev). I have tried running R as root, all to no avail.

I've found two other accounts of this problem:

Ubuntu 12.04 R install.packages() does not work. No warning, no install

install.packages() Rstudio server AWS ubuntu error

And have tried the suggested solutions, but none of them work for me.

A little more background on my install procedures; here is the sequence of commands I used to install R in ubuntu:

    sudo apt-get update
    echo "deb http://http://ftp.osuosl.org/pub/cran/bin/linux/ubuntu trusty/" >> ./sources.list.appendme
    sudo cat /etc/apt/sources.list ./sources.list.appendme  > ./sources.list.tmp
    sudo mv ./sources.list.tmp /etc/apt/sources.list
    rm ./sources.list.appendme
    sudo apt-get install r-base
    sudo apt-get install r-base-dev
    sudo apt-get --reinstall install r-base-dev

This follows the instructions found here: http://cran.r-project.org/bin/linux/ubuntu/README for installation of R in Ubuntu.

Here are the install steps I used to make my virtual machine:

> vagrant box add july24
> https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-i386-vagrant-disk1.box
> vagrant init july24 vagrant up

Here is a comparison of the output I get from running the package installation in my OS X R installation and my Ubunutu R installation. Interestingly, the downloaded package sizes are generally much smaller in the Ubunutu attempt (47KB and 26KB in OS X's R, vs 14KB and 0.9257KB in the Ubuntu R). Not sure if this is a difference between R versions (3.0.3/3.0.2 in OS X/Ubunutu), or because of different reqs for the different OSs..

Correct, error-free package installation in OS X:

install.packages("dataview",repos="http://cran.cs.wwu.edu")

also installing the dependency ‘xtermStyle’

trying URL 'http://cran.cs.wwu.edu/bin/macosx/contrib/3.0/xtermStyle_2.2-4.tgz' Content type 'application/x-gzip' length 49060 bytes (47 Kb) opened URL ================================================== downloaded 47 Kb

trying URL 'http://cran.cs.wwu.edu/bin/macosx/contrib/3.0/dataview_2.0-9.tgz' Content type 'application/x-gzip' length 27032 bytes (26 Kb) opened URL ================================================== downloaded 26 Kb

The downloaded binary packages are in /var/folders/sy/w_z0czvs2nqd2ys0vf_827zc0000gn/T//RtmpOlT9rM/downloaded_packages

library('dataview')

Loading required package: xtermStyle

installation with the error in Ubuntu:

install.packages("dataview",repos="http://cran.cs.wwu.edu")

Installing package into ‘/home/vagrant/R/i686-pc-linux-gnu-library/3.0’ (as ‘lib’ is unspecified) also installing the dependency ‘xtermStyle’

trying URL 'http://cran.cs.wwu.edu/src/contrib/xtermStyle_2.2-4.tar.gz' Content type 'application/x-gzip' length 15265 bytes (14 Kb) opened URL ================================================== downloaded 14 Kb

trying URL 'http://cran.cs.wwu.edu/src/contrib/dataview_2.0-9.tar.gz' Content type 'application/x-gzip' length 9257 bytes opened URL ================================================== downloaded 9257 bytes

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

library('dataview')

Error in library("dataview") : there is no package called ‘dataview’

library('dataview',lib.loc='/home/vagrant/R/i686-pc-linux-gnu-library/3.0')

Error in library("dataview", lib.loc ="/home/vagrant/R/i686-pc-linux-gnu-library/3.0") :
there is no package called ‘dataview’

Maybe there is something I am missing? Your help or suggestions are greatly appreciated.

Community
  • 1
  • 1
samhiggins2001
  • 318
  • 2
  • 12

3 Answers3

4

Ok, so I was running into the same problem... Make sure you allocate enough memory to your VM. The default VM memory for Vagrant is 512m... Increase it to 2048m and all should work fine...

I use this in my vagrant file to increase the memory:

  config.vm.provider "virtualbox" do |vb|
    # Use VBoxManage to customize the VM. For example to change memory:
    vb.customize ["modifyvm", :id, "--memory", "2048"]
  end
Ben B
  • 779
  • 6
  • 4
0

Yes Ben B, that was the key.
Though, there was a slight modification needed to get past a few errors: not sure how my configuration was different, but this is the Vagrantfile addition that would actually work in the end:

config.vm.provider :virtualbox do |virtualbox|
  # allocate 1024 mb RAM
  virtualbox.customize ["modifyvm", :id, "--memory", "2024"] 
end

My vagrant installations are pretty basic right now -- using almost all of the default options. Perhaps that's why the working solution differed ever so slightly...

samhiggins2001
  • 318
  • 2
  • 12
-2

I am not sure why you running R via a virtual machine. You can run R either on OS X or Ubuntu. However, the first step I would take is to download RStudio; it is an IDE for R. From there you should be able to download packages as needed within the IDE.

 install.packages('testthat')
j riot
  • 544
  • 3
  • 6
  • 16
  • The virtual machine is running inside my mac book, Ubuntu is running inside of the virtual machine. R is running in Ubuntu. It is all command line, so Rstudio is not an option. In the end, the R scripts will be part of a data processing pipeline run on AWS to pre-process and analyze data before it is input to a database. – samhiggins2001 Jul 25 '14 at 01:16
  • Ok. I am not 100% sure how to do this as I scritly run R on Ubuntu without a VM. However, maybe this documentation can help: http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-packages – j riot Jul 25 '14 at 16:26