我正在尝试创建一个应用程序,该应用程序首先选择在单独的脚本do_data.R中生成的数据子集,然后通过用户选择的几个指标过滤该子集来过滤数据。
我的复制示例如下所示:
我的ui.R文件是:
source("do_label.R")
shinyUI(fluidPage(theme = shinythemes::shinytheme("lumen"),
fluidRow(
column(width = 8, includeMarkdown("intro_data.md")),
column(width = 4, includeHTML("intro_logo.html"))
),
sidebarLayout(
sidebarPanel(
selectInput("indicator", "Indicator:", choices = indicator),
selectInput("category", "Category:", choices = category)
sliderInput("year", "Year:", min = 2011, max = 2016, value = 1, sep = "")
),
mainPanel(
tabsetPanel(
tabPanel('Data', DT::dataTableOutput('ex1')),
tabPanel('Graphs', DT::dataTableOutput('ex2'))
)
))
))
我的server.R文件是:
library(readr)
library(dplyr)
source("do_data.R")
# Load the dataset
loadData <- function() {
df <- surveydata
return(df)
}
getTable <- function(df, reaction){
if(input$indicator == "df1")
return(df1)
else
return(df1)
}
##### GLOBAL OBJECTS #####
# Shared data
globalData <- loadData()
##### SHINY SERVER #####
# Create shiny server.
shinyServer(function(input, output) {
cat("Press \"ESC\" to exit...\n")
# Copy the data frame
localFrame <- globalData
getReaction4 <- reactive({
return(list(indicator = input$indicator
))
}) # getReaction4
# Output table.
output$table = DT::renderDataTable({print(getTable(localFrame, getReaction4()))} # output table
})
我的问题是我的子集df1和df2根本没有显示,sidebarPanel似乎完全不起作用。您能否就我在这里遗漏的内容提供一些基本建议?
问候