【发布时间】:2021-04-11 01:19:26
【问题描述】:
我在https://www.shinyapps.io/ 上有一个 shinnyapp,我通常可以使用“发布”按钮部署该应用程序。
但是我想改用deployApp 函数,如下面的代码:
rsconnect::deployApp("~/Documents/R/shinny",appName="myapp", account="myaccount")
但是当使用deployApp 函数时,它会在网络浏览器上出现错误:
An error has occurred
The application failed to start: exited unexpectedly with code 1
Attaching package: ‘dplyr’
The following objects are masked from ‘package:plyr’:
arrange, count, desc, failwith, id, mutate, rename, summarise,
summarize
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
Error in value[[3L]](cond) : could not find function "dashboardPage"
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
所以如果按下按钮,没问题,但如果我使用该功能就会出错。
我的 Rscript 结构如下(函数内有更多代码,但我保持简单举例说明)
library(shinydashboard)
library(shiny)
library(ggplot2)
library(dplyr)
library(scales)
library(lubridate)
library(zoo)
library(reshape2)
library(scales)
library(ggrepel)
library(stringr)
load("sales.RData")
sidebar <- dashboardSidebar(
)
)
body <- dashboardBody(
)
ui <- fluidPage(dashboardPage(
dashboardHeader(),
sidebar,
body
)
)
server <- function(input, output) {
}
# Run the application
shinyApp(ui = ui, server = server)
rsconnect::deployApp('C:\\Users\\Repro\\Documents\\R\\SHINY',
appFiles = c('app.R','sales.RData','www/custom.css'),
account = 'myaccount', server = 'shinyapps.io')
可能是什么问题?
谢谢
【问题讨论】:
-
是
library(shiny)还是library(shinydashboard)在你的脚本的头部? -
你好。两者都包括在内。
-
您的应用程序是否构建在包含所有脚本的 Rproject 中? (也许是一个假设,因为我们没有你的脚本,所以这并不容易)。
-
你好。我已经用我的应用程序结构更新了这个问题。希望能澄清一下。
-
你好。当我部署应用程序时,我没有将路径放入参数中,我使用 RStudio 将我的应用程序构建为 Rproject,然后直接运行
rsconnect::deployApp()而不使用任何参数。你可以试试这个吗?