我可以开发一款需要其他套餐的R Shiny应用程序吗?例如,
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")
})
}
)
运行应用
> 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)
我在本地机器上得到了这个结果,
但是当我尝试部署应用程序时,我发现下面的错误,
> 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
发生了什么事?这是否意味着我不能将本机R与其他软件包(例如openair)集成/导入?
修改
> require(openair)
> deployApp()
Uploading application bundle...
Error in setwd(bundleDir) : cannot change working directory
答案 0 :(得分:2)
您不能在部署的应用中使用setwd()
绝对路径,因为您不再在计算机上,而是在不同的服务器上。您只能使用setwd()
与app文件夹的相对路径。