gpt4 book ai didi

r - setwd(bundleDir) 错误 : cannot change working directory

转载 作者:行者123 更新时间:2023-12-04 14:32:30 27 4
gpt4 key购买 nike

我可以开发需要其他软件包的 R Shiny 应用程序吗?例如,

ui.R,

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

sidebarPanel("side bar"),

mainPanel(
plotOutput("myPlot")
)

)

)

服务器.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)

我在本地机器上得到这个结果,

enter image description here

但是当我尝试部署应用程序时,我在下面遇到了这个错误,

> 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

这是怎么回事?这是否意味着我无法将 native R 与其他包(例如 openair)集成/导入?

编辑:

> require(openair)
> deployApp()

Uploading application bundle...
Error in setwd(bundleDir) : cannot change working directory

最佳答案

您不能在部署的应用程序中使用带有绝对路径的 setwd(),因为您不再在您的计算机上,而是在不同的服务器上。您只能将 setwd() 与您的应用程序文件夹的相对路径一起使用。

关于r - setwd(bundleDir) 错误 : cannot change working directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29794075/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com