3

Can I develop a R Shiny app that requires other packages? For instance,

ui.R,

shinyServer(
  pageWithSidebar(
    headerPanel("Shiny App"),

    sidebarPanel("side bar"),

    mainPanel(
      plotOutput("myPlot")
      )

    )

)

server.R,

shinyServer(

  function(input, output, session) {

    output$myPlot = renderPlot({

      library("openair")
      scatterPlot(selectByDate(mydata, year = 2003), x = "nox", y = "no2",
                  method = "density", col = "jet")
    })
  }

)

Run the app,

> runApp()

Listening on http://127.0.0.1:4459
Loading required package: lazyeval
Loading required package: dplyr

Attaching package: ‘dplyr’

The following object is masked from ‘package:stats’:

    filter

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

Loading required package: maps
(loaded the KernSmooth namespace)

I get this result on my local machine,

enter image description here

But when I try to deploy the app, I this this error below,

> setwd("C:/.../myapp")
> library(shiny)
> library(shinyapps)

Attaching package: ‘shinyapps’

The following object is masked from ‘package:shiny’:

    hr

> deployApp()
Preparing to deploy application...DONE
Uploading application bundle...
Error in setwd(bundleDir) : cannot change working directory

What is going on? Does it mean that I cannot integrate/ import the native R with other packages (for instance openair)?

EDIT:

> require(openair)
> deployApp()

Uploading application bundle...
Error in setwd(bundleDir) : cannot change working directory
zx8754
  • 52,746
  • 12
  • 114
  • 209
Run
  • 54,938
  • 169
  • 450
  • 748

1 Answers1

3

You cannot use setwd() with absolute path in deployed app, since you are not on your computer anymore but on a different server. You can only use setwd() with relative path to your app folder.

mathielo
  • 6,725
  • 7
  • 50
  • 63
Julien Colomb
  • 508
  • 4
  • 20