【问题标题】:Error in setwd(bundleDir) : cannot change working directorysetwd(bundleDir) 中的错误:无法更改工作目录
【发布时间】:2015-06-29 21:43:10
【问题描述】:

我可以开发需要其他软件包的 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)

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

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

> 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

【问题讨论】:

  • 如果这是一个依赖问题,请参阅?shinyapps::appDependencies。它可能会有所帮助。
  • ?shinyapps::appDependencies在哪里?
  • @teelou 只需在 R 中输入 ?shinyapps::appDependencies
  • @Pascal。谢谢,但我仍然遇到同样的错误。请看我上面的编辑。
  • 您是否尝试以管理员身份运行 Rstudio?

标签: r shiny openair


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-10
    • 2015-04-25
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 2022-07-15
    • 1970-01-01
    • 2023-01-17
    相关资源
    最近更新 更多