Packages missing from the brilliant server

I am trying to create a web application using brilliant. I need to download the package that I installed on my computer. For example:

## Contents ui.R: library(shiny) library(plyr) shinyUI(pageWithSidebar( headerPanel("Hello Shiny!"), sidebarPanel( sliderInput("obs", "Number of observations:", min = 0, max = 1000, value = 500) ), mainPanel( plotOutput("distPlot") ) )) ## Contents server.R: library(shiny) library(plyr) shinyServer(function(input, output) { output$distPlot <- renderPlot({ # generate an rnorm distribution and plot it dist <- rnorm(input$obs) hist(dist) }) }) 

This works fine if I run it locally (using runApp ), but when I try to run it through my server (the same computer), I get an error that the plyr package (or any other package that I try to use this way ) not installed. How can I use additional packages on a brilliant server?

+2
r shiny shiny-server
source share
5 answers

Compare the output of .libPaths() in both cases and configure it accordingly in the server / script instance.

You can, for example, have packages in your package directory R, ​​which the server cannot access. System-wide package installations are preferable in such cases, and this is, for example, the default on Debian / Ubuntu.

+7
source share

The problem is that the brilliant server cannot find the packages that you are installing, because it runs them as another user called shiny . This user is created when a brilliant server is installed.

The easiest (and safest IMHO) way to solve this is to simply install the packages as a brilliant user by following these steps.

  • Set a password for the user using sudo passwd shiny , enter and confirm the password
  • Switch to a brilliant account using: su - shiny
  • Call R with $ R (without sudo)
  • Install the necessary packages, in this case: install.packages("plyr")

Please note that if you have rstudio-server installed on one computer, you can perform steps 2-4 using this interface. Just go to the same / ip domain and use: 8787 for the rstudio-server interface instead of: 3838 for a brilliant server.

Adapted from my answer here .

+5
source share

There may be a solution that does not spoil the system library. Put the following code at the top of server.R .

 user <- unname(Sys.info()["user"]) if (user == "shiny") { # Set library locations .libPaths(c( "/path/to/your/own/library" ) ) } 

This allows Shiny to search for packages installed in your own library, and also supports the packages you use to develop the application and the packages used to deploy the application in synchronization.

Note that you may need to set permissions for your library folder for shiny user to see it correctly. Otherwise, he will not be able to look at the location you specified without an error message.

+1
source share

I upgraded from R 3.2 to 3.4 and ran into the same problem, then created a folder named 3.4 in R / x86_64-pc-linux-gnu-library / and copied everything from folder 3.2 (which already exists in the same place).

0
source share

Why do you need Plir? nothing is used in the code; but in any case, you can install packages on Linux R by running R, then install.packages ('plyr');

-2
source share

All Articles