R 为什么输入$tableid\u all\u行(DT)以闪亮的方式工作?
我有以下应用程序:R 为什么输入$tableid\u all\u行(DT)以闪亮的方式工作?,r,shiny,dt,R,Shiny,Dt,我有以下应用程序: ... selectInput("cars", "Pick a Car: ", c("All" = "All Cars", "Ford" = "Ford", "Volvo" = "Volvo", "Ferrari" = "Ferra
...
selectInput("cars", "Pick a Car: ",
c("All" = "All Cars",
"Ford" = "Ford",
"Volvo" = "Volvo",
"Ferrari" = "Ferrari",
"Fiat" = "Fiat",
"Merc" = "Merc"))
)),
shinySaveButton("save", "Save file", "Save file as ...", filetype=list(csv="csv")),
DT::dataTableOutput('table1')
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
mtcars$car <- rownames(mtcars)
output$table1 <-renderDataTable({
mtcars %>%
filter(stringr::str_detect(car, as.character(input$cars)) | input$cars == 'All Cars')
})
observe({
volumes <- c("UserFolder"="~/Documents/R1/DwnLdWord/saves")
shinyFileSave(input, "save", roots=volumes, session=session)
fileinfo <- parseSavePath(volumes, input$save)
data <- input$table1_rows_all
if (nrow(fileinfo) > 0) {
write.csv(data, fileinfo$datapath)
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
。。。
选择输入(“车辆”,“选择车辆:”,
c(“所有”=“所有汽车”,
“福特”=“福特”,
“沃尔沃”=“沃尔沃”,
“法拉利”=“法拉利”,
“菲亚特”=“菲亚特”,
“Merc”=“Merc”))
)),
shinySaveButton(“保存”、“保存文件”、“将文件另存为…”),filetype=list(csv=“csv”),
DT::dataTableOutput('table1')
)
)
#定义绘制直方图所需的服务器逻辑
服务器检查以下内容:
server <- function(input, output, session) {
mtcars$car <- rownames(mtcars)
output$table1 <-renderDataTable({
mtcars %>%
filter(stringr::str_detect(car, as.character(input$cars)) | input$cars == 'All Cars')
})
observe({
volumes <- c("UserFolder"="~/Documents/R1/DwnLdWord/saves")
shinyFileSave(input, "save", roots=volumes, session=session)
fileinfo <- parseSavePath(volumes, input$save)
data <- mtcars[input$table1_rows_selected,]
if (nrow(fileinfo) > 0) {
write.csv(data, fileinfo$datapath)
}
})
}
# Run the application
shinyApp(ui = ui, server = server)
服务器谢谢!我要给它一点时间看看会发生什么:P