RStudio Shiny ERROR: there is no package called "shinydashboard"
Asked Answered
G

6

15

I am trying to get http://rstudio.github.io/shinydashboard/ working on my Ubuntu 14.10 laptop.

I followed the installation instructions here:

http://rstudio.github.io/shinydashboard/get_started.html

Basic shiny pages work. For example:

http://localhost:3838/sample-apps/hello/

But when I try one of the shinydashboard examples, I get the error:

http://localhost:3838/sample-apps/shiny/

ERROR: there is no package called "shinydashboard"

If I run an R session in a terminal, I can load the shinydashboard library, and I get a browser window with the dashboard if I copy+paste this code in the R session:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

It says:

Attaching package: 'shinydashboard'

The following object is masked from 'package:graphics':

    box

> 
> ui <- dashboardPage(
+   dashboardHeader(),
+   dashboardSidebar(),
+   dashboardBody()
+ )
> 
> server <- function(input, output) { }
> 
> shinyApp(ui, server)

Listening on http://127.0.0.1:7093

I tried to install the devel version of the shiny server, but that also didn't help. Here is my sessionInfo():

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

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

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

other attached packages:
[1] shinydashboard_0.2.3 shiny_0.11.1.9002   

loaded via a namespace (and not attached):
 [1] bitops_1.0-6    devtools_1.7.0  digest_0.6.8    htmltools_0.2.6
 [5] httpuv_1.3.2    httr_0.6.1      mime_0.2        R6_2.0.1       
 [9] Rcpp_0.11.3     RCurl_1.95-4.5  stringr_0.6.2   tools_3.1.1    
[13] xtable_1.7-4   

EDITED:

More info:

ls -ld /usr/local/lib/R/site-library
drwxrwsr-x 11 root staff 4096 Mar  1 12:47 /usr/local/lib/R/site-library

Any ideas why I is it not working on http://localhost:3838 ? Which packaged need installing as root ?

Guerrilla answered 1/3, 2015 at 13:48 Comment(1)
You don't have shinydashboard installed.Ial
B
22

The problem is that shiny-server cannot find the packages that you install because it runs them as a different user which is called shiny. This user is created upon installation of shiny-server

The easiest (and safest IMHO) way to solve this is to just install the packages as the shiny user, using the following steps.

  1. Set a password for the user using sudo passwd shiny, now enter and confirm a password
  2. Switch to the shiny account using: su - shiny
  3. Call up R using $ R (without sudo)
  4. Install the required packages, in this case: install.packages("shinydashboard")

Note that if you have rstudio-server installed on the same machine then you can perform steps 2-4 using that interface. Simply go the same domain/ip and use :8787 for the rstudio-server interface instead of :3838 for shiny-server.

Bird answered 7/10, 2015 at 15:30 Comment(1)
Thank-you. Very helpful answer.Franny
K
6

On Ubuntu (and Debian) you have several choices.

  1. Do ls -ld /usr/local/lib/R/site-library and note that the directory is owned by group adm. Make yourself part of that group, or alternatively change the group to one you are a member of. Now you can just write to that directory, so a plain old install.packages() will work.

  2. Use littler via sudo apt-get install littler and its handy script(s) install.r and install2.r. I use these a lot from the command-line on numerous machines at work and home. Then this is as simple as install.r shinydashboard (once you copied or linked install.r somewhere into your $PATH).

  3. If you insist, use a sledgehammer and start R as root. That is generally not a good idea due to permissions escalation.

Kerikeriann answered 3/3, 2015 at 14:48 Comment(5)
Cool, I will try that. How do I "make myself part of the group". Excuse my naivete...Guerrilla
The are a number of ways. Via the Settings GUI in Ubuntu, via the adduser command, ... Maybe see here on askubuntu where this simple query gave 1300+ results.Kerikeriann
Trying this now: sudo gpasswd -a ${USER} staffGuerrilla
@DirkEddelbuettel would this first option work on Fedora?Bird
"Possibly" but some things hinge on details (eg value of what .libPaths() returns for you) so you better ask on the r-sig-fedora list.Kerikeriann
T
2

If you use Shiny Server, all your R packages need to be installed with root privilege. See Section 1.3.4 of the Shiny Server admin guide for more details.

Titanium answered 3/3, 2015 at 14:42 Comment(1)
That's pretty bad advice as it opens sudo to anything triggered from a semi-randomly pulled-in package. Instead, run as a user who is part of the group owning the directory. On Debian/Ubuntu this works out of the box and does not require sudo -- only local admin cooperation to make you part of that group.Kerikeriann
G
1

This answer should work: https://mcmap.net/q/764611/-rstudio-shiny-error-there-is-no-package-called-quot-shinydashboard-quot

I now realised it was a permissions issue when installing packages as R instead of sudo R.

I momentarily resolved it by installing as $USER and then pointing to the library with lib.loc:

library(shinydashboard, lib.loc="/home/avilella/R/x86_64-pc-linux-gnu-library/3.1")
Guerrilla answered 3/3, 2015 at 16:38 Comment(1)
I personally do not like directories below $HOME as other users cannot see them.Kerikeriann
P
1

To install the library in sudo.

1- su #to be in mode sudoer 2- tape the password 3- R 4- install.packages('shinydashboard')

Packing answered 5/1, 2017 at 11:21 Comment(0)
C
1

I have the similar problem for "d3heatmap" package. It runs in RStudio (desktop and web) but gets an error in the web browser.

The only one workable solution was to install package from R command line under "root" account.

Cabstand answered 25/9, 2017 at 19:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.