3

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

1 回答 1

3

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

于 2016-07-01T12:43:01.983 回答