如何使用checkboxgroup输入在R闪亮中提出数据表?(How do I use checkboxgroup input to come up with a datatable in R shi

编程入门 行业动态 更新时间:2024-10-14 16:26:07
如何使用checkboxgroup输入在R闪亮中提出数据表?(How do I use checkboxgroup input to come up with a datatable in R shiny?) 我正在使用DT包中的数据表 尝试使用checkboxgroup输入,以便我可以为表的输出选择多个变量

我研究没有谷歌找到一些示例代码,但很难申请。

任何专家都可以帮忙!?

谢谢!!

I am using datatable from DT package trying to use checkboxgroup input so that I can select multiple variables for table's output

I have researching no google to find some example codes but it was hard to apply.

Any experts can help!?

Thank you!!

最满意答案

您可以根据复选框输入使用[]对数据进行子集化。

library(shiny) shinyApp( fluidPage( checkboxGroupInput('checkbox', 'select columns', names(mtcars), inline = TRUE), DT::dataTableOutput('table') ), function(input, output) output$table <- DT::renderDataTable({ mtcars[input$checkbox] }) )

编辑 :这里有一些代码来说明我在评论中提到的内容

library(shiny) shinyApp( fluidPage( checkboxGroupInput('checkbox', 'select columns', unique(mtcars$gear), unique(mtcars$gear), inline = TRUE), DT::dataTableOutput('table') ), function(input, output) output$table <- DT::renderDataTable({ subset(mtcars, gear %in% input$checkbox) }) )

You can use [] to subset your data according to the checkbox input.

library(shiny) shinyApp( fluidPage( checkboxGroupInput('checkbox', 'select columns', names(mtcars), inline = TRUE), DT::dataTableOutput('table') ), function(input, output) output$table <- DT::renderDataTable({ mtcars[input$checkbox] }) )

EDIT: Here is some code to illustrate what I mentioned in the comments

library(shiny) shinyApp( fluidPage( checkboxGroupInput('checkbox', 'select columns', unique(mtcars$gear), unique(mtcars$gear), inline = TRUE), DT::dataTableOutput('table') ), function(input, output) output$table <- DT::renderDataTable({ subset(mtcars, gear %in% input$checkbox) }) )

更多推荐

本文发布于:2023-08-07 00:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456570.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   数据表   checkboxgroup   shiny   input

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!