Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - shiny server on Ubuntu

I'm fairly new to R, Shiny, Shiny Server and Ubuntu 12.04. After a long day I've got just about everything working except for actually having shiny-server host my app. I'm trying to host my app locally.

This is my error:

Error in library(ggplot2) : there is no package called ‘ggplot2’ Calls: runApp ...
startAppDir -> sys.source -> eval -> eval -> library 
Execution halted

And here is some relevant info generated by >sessionInfo():

R version 3.0.3 (2014-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] gridExtra_0.9.1 shiny_0.9.1     ggplot2_0.9.3.1

loaded via a namespace (and not attached):
 [1] bitops_1.0-6       caTools_1.16       colorspace_1.2-4   dichromat_2.0-0   
 [5] digest_0.6.4       gtable_0.1.2       httpuv_1.2.3       labeling_0.2      
 [9] MASS_7.3-30        munsell_0.4.2      plyr_1.8.1         proto_0.3-10      
[13] RColorBrewer_1.0-5 Rcpp_0.11.1        reshape2_1.2.2     RJSONIO_1.0-3     
[17] scales_0.2.3       stringr_0.6.2      tcltk_3.0.3        tools_3.0.3       
[21] xtable_1.7-3      
> 

I tested without shiny-server and the app works fine

runApp("/var/shiny-server/www/examples/MY_APP/")

I've also tested the examples that came with shiny-server and they work fine but they don't use ggplot2.

ggplot2 is clearly installed so I suspect it's a permission issue (?) but I don't know how to fix it...

Thanks for your help !

*SOLUTION* Using .libPaths() I was able to determine that custom packages installed by

>install.packages("ggplot2")

are placed in the main directory

/home/USER/R/x86_64-pc-linux-gnu-library/3.0/ggplot2

I had to copy every file from folder '~3.0/' into

/usr/local/lib/R/site-library

It works now! Thanks :D

like image 833
Soran Avatar asked Oct 01 '22 05:10

Soran


1 Answers

Try installing ggplot2 package to the system directory (not local user directory), by running

sudo R
(within R session)
install.packages('ggplot2')

Since shiny may run under a different user name, it may not have access to your locally installed R libraries.

like image 154
Victor K. Avatar answered Oct 12 '22 08:10

Victor K.