【发布时间】:2017-09-10 12:08:40
【问题描述】:
我正在尝试从上传到应用程序的“汽车”数据集中获取速度变量。基本上在选择速度下:我希望所有数字都出现在数据集$速度中。在 selectInput 下,选择应该取决于我使用 fileInput 上传的数据集。我怎样才能完成这个任务。现在我已将选项添加为 1、2、3。理论上应该有汽车数据集的速度变量的所有值。
library(shiny)
library(datasets)
##the file I am uploading
data(cars)
dataset=write.csv(cars, "dataset.csv")
ui=fluidPage(
actionButton("upload", "Upload File"),
bsModal("uploadFile", " ", "upload",
sidebarLayout(
sidebarPanel(
fileInput("file","Choose file to upload")
),
mainPanel(
tableOutput("contents")
)
)
),
sidebarLayout(
sidebarPanel(
column(3, selectInput("selectElement", "Select speed:", c(1,2,3),multiple =
T, selectize = F)
)
),
mainPanel(
)
)
)
server=function(input,output,session){
output$contents <- renderTable({
inFile <- input$file
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath)
})
}
shinyApp(ui,server)
【问题讨论】: