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,

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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With