install.packages() Rstudio server AWS ubuntu error

2019-08-02 17:54发布

问题:

I have an AWS instance running ubuntu 12.04 and shiny server as well as Rstudio, however, when I try to add packages, I get an error when trying to load the library()

for the following command: install.packages("jsonlite", dependencies = TRUE, repos="http://cran.cs.wwu.edu") terminal output shows the download happens without any issues with the following as the last line The downloaded source packages are in ‘/tmp/RtmpO02nLU/downloaded_packages’

Clearly library() shows an error eg// Error in library(jsonlite) : there is no package called ‘jsonlite’ Is there something wrong with this process? how can I install packages to work with my Instance/ environment?

EDIT:: I realise there is the option of creating a swap file, wondering with the t1 instance, is there something really inefficient with the set up? rather than doing this or just upgrading the instance with throwing more memory at it..

回答1:

You may want to sudo R to run R. Otherwise it won't allow you to install R package into the R library directory. Once you sudo R, then use install.packages again. Hope it works for you. I had similar problem before.



回答2:

I had the same issue using a Virtual Machine through vagrant.

After updating the R version, I got the useful warning that the installation of the R package shiny failed because of lack of memory. I was using 512 Mb for RAM, this is not enough. After tweaking the Vagrantfile:

config.vm.provider "virtualbox" do |vb|
  # Customize the amount of memory on the VM:
  b.memory = "2048"
end

It worked out. Of note, to install dplyr I had to increase the virtual memory to 2048 Mb.

Hope this helps