使用过滤的数据表在闪亮 [英] Using filtered datatables in shiny
问题描述
我是新的闪亮的
,但是想知道是否有任何方法可以将已过滤的数据表(使用列过滤器)存储在 R
对象,以便将此过滤的数据传递到直方图和绘图功能。
I am new to shiny
but was wondering if there is any way to store a filtered datatable (using the column filters) in a R
object so that this filtered data can be passed to histogram and plot functions.
编辑5月7日,15日:包括作者从评论中扩展的解释
EDIT May 7, 15: Including the author's expanded explanation from comments
我希望使用内置列过滤器和
然后想要绘图自动调整。我已经尝试了DT
包,但是我不太喜欢这个包的
的列过滤器,因为这是不可能的(我想)删除
过滤器从表的一列子
I want the table to get filtered using the built-in column filters and then want the plot to automatically adjust. I've already tried the DT package but I don't like very much of the column filters that come with this package as it is not possible (I think) to remove the filters from a subset of the columns in the table
推荐答案
只需建立@ JasonAizkalns的例子,您可以使用jQuery隐藏一些内置的列过滤器。例如这里,前两个隐藏:
Just building up on @JasonAizkalns's example, you can hide some of the built-in column filters using jQuery. for example here the first two are hidden:
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(dataTableOutput('tbl'),
plotOutput('plot1')),
server = function(input, output) {
output$tbl = renderDataTable({
datatable(iris, filter="top",options = list(lengthChange = FALSE),callback=JS("
//hide column filters for the first two columns
$.each([0, 1], function(i, v) {
$('input.form-control').eq(v).hide()
});"))
})
output$plot1 = renderPlot({
filtered_data <- input$tbl_rows_all
hist(iris[filtered_data, "Sepal.Length"])
})
}
)
这篇关于使用过滤的数据表在闪亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!