为什么闪亮的仪表板加载时间太长?
Why shiny dashboard is taking too long to load?
Objective
你好,我有两个数据集。我想通过在 shinydashboard
.
中使用 radioButtons
一次 select
问题
在 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)
没有错误信息。我做错了什么?
我不确定你到底想绘制什么,所以这里有一个例子:
ui.R
中的单选按钮的工作方式如下:
radioButtons("radio", label = h3("Select the Dataset (first 5 minutes)"),
choices = c("US-101" = 1, "I-80" = 2),
selected = 1)
对于 server.R
你需要这样的东西:
output$plot = renderPlot({
switch(input$radio,
`1` = hist(df10151$Var),
`2` = hist(df8051$Var)
})
Objective
你好,我有两个数据集。我想通过在 shinydashboard
.
radioButtons
一次 select
问题
在 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)
没有错误信息。我做错了什么?
我不确定你到底想绘制什么,所以这里有一个例子:
ui.R
中的单选按钮的工作方式如下:
radioButtons("radio", label = h3("Select the Dataset (first 5 minutes)"),
choices = c("US-101" = 1, "I-80" = 2),
selected = 1)
对于 server.R
你需要这样的东西:
output$plot = renderPlot({
switch(input$radio,
`1` = hist(df10151$Var),
`2` = hist(df8051$Var)
})