几个小时我一直在苦苦挣扎.我Shiny App应该在R环境中显示一些变量.它的工作正常但是当我将它部署到网络时,我得到的错误如下:
Error: object 'df1' not found
Run Code Online (Sandbox Code Playgroud)
如何添加df1和我的其他数据框,以便它们可以作为Shiny App部署时的一部分打包?
请帮忙.这是我的示例代码:
server.R
library(shiny)
shinyServer(function(input,output){
output$datasets <- renderTable({
switch(input$choice,
"1" = as.data.frame(df1)
"2" = as.data.frame(df2) })
}))
Run Code Online (Sandbox Code Playgroud)
UI.R
shinyUI(
fluidPage(theme = "bootstrap.css",
sidebarPanel(
conditionalPanel(
condition = "input.theTab == 'datasets' ",
h3('Display Sample Data'),
selectInput("choice", "Selection", choices = c("Group1"=1,"Group2"=2)),
)),
mainPanel(
tabsetPanel(
tabPanel( "datasets", tableOutput("datasets"), value = 'datasets'),
id = "theTab"))
)
Run Code Online (Sandbox Code Playgroud)
终于找到解决办法了!!基本上我应该在文件顶部加载我的工作区UI.R。这边走:
attach("myWorkspace.RData")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2427 次 |
| 最近记录: |