目標
嗨,我有兩個數據集。我想通過使用radioButtons
在shinydashboard
中一次選擇一個。爲什麼閃亮的儀表板加載時間過長?
問題
在app.R
文件,我首先加載兩個數據集(71 MB和103 MB的大小)。下面的代碼工作,只需要幾秒鐘的應用負載:
工作代碼:
library(shiny)
library(dplyr)
library(shinydashboard)
# Global
df10151 <- read.csv("Data/df1015.csv", header = TRUE)
df8051 <- read.csv("Data/df805.csv", header = TRUE)
# UI
ui <- dashboardPage(
dashboardHeader(title = "Driving States"),
dashboardSidebar(
sliderInput("fid", "Frame ID:",
min = 0, max = 50, value = 3, step = 0.1
)))
# Server
server <- function(input, output, session) {
}
shinyApp(ui, server)
但是,當我加入radioButtons
,它永遠需要並不會加載:
代碼失敗:
library(shiny)
library(dplyr)
library(shinydashboard)
# Global
df10151 <- read.csv("Data/df1015.csv", header = TRUE)
df8051 <- read.csv("Data/df805.csv", header = TRUE)
# UI
ui <- dashboardPage(
dashboardHeader(title = "Driving States"),
dashboardSidebar(
radioButtons("radio", label = h3("Select the Dataset (first 5 minutes)"),
choices = list("US-101" = df10151, "I-80" = df8051),
selected = NULL),
sliderInput("fid", "Frame ID:",
min = 0, max = 50, value = 3, step = 0.1
)))
# Server
server <- function(input, output, session) {
}
shinyApp(ui, server)
沒有錯誤信息。我究竟做錯了什麼?
目前還不清楚你想用單選按鈕做什麼。您無法將數據集傳遞給選擇選項。請看看http://shiny.rstudio.com/gallery/radio-buttons.html – Divi
@Divi這個程序是不完整的。我想從兩個數據集中選擇一個,然後繪製其中的一部分。對於選擇我使用'radioButtons' –
你是什麼意思「它不加載」 - 什麼不加載? – SymbolixAU