R闪亮的dataTableOutput不显示刷新点 [英] R Shiny dataTableOutput not displaying Brushed Points

查看:220
本文介绍了R闪亮的dataTableOutput不显示刷新点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ggplot2数据集中的Iris数据开发R Shiny仪表板。
它有三个主要组成部分,一个用于选择要显示在图中的变量的侧栏面板,一个带有刷点的ggplot和一个数据表,其中显示了刷点的数据。
除了数据表似乎没有选择表格上的数据点之外,一切都完美无缺。从我可以告诉它与服务器中的输出$ plot_brushed_points 行有关。
任何帮助将不胜感激!

I'm developing an R Shiny dashboard using the Iris data in the ggplot2 dataset. It has three main components, a sidebar panel to select the variables to display in the plot, a ggplot with brushed points and a datatable below which shows the data of the brushed points. Everything works perfectly except the datatable does not seem to select the data points on the table. From what I can tell it has something to do with the line output$plot_brushed_points in the server. Any help would be greatly appreciated!

library(shiny)
library(ggplot2)

useri <- shinyUI(pageWithSidebar(
headerPanel("Reactive Plot"),
sidebarPanel(
selectInput('x','X-Axis',names(iris)),
selectInput('y','Y-Axis',names(iris)),
selectInput('color','Color',c('None',names(iris[5])))),
mainPanel(uiOutput("plotui"),dataTableOutput("plot_brushed_points"))))

serveri <- shinyServer(function(input,output) {
output$plot <- renderPlot({
p <- ggplot(iris,aes_string(x=input$x, y=input$y))+geom_point()+theme_bw()
if(input$color != 'None')
  p <- p + aes_string(color=input$color)
print(p)
})
output$plotui <- renderUI(plotOutput("plot",brush = brushOpts("plot_brush")))
output$plot_brushed_points <- renderDataTable(brushedPoints(iris,input$plot_brush,input$x,input$y), options=list(searching=FALSE, paging = FALSE))
})

shinyApp(useri, serveri)

我应该注意到数据表显示你可以看到它刷新,它只是没有填充任何数据。

I should note that the data table displays and you can see it refresh, it just doesn't fill with any data.

编辑

上面的脚本有一个功能,它显示数据表中的所有值,当且仅当您选择绘图的整个区域时。

The script above has a feature where it displays all the values in the data table if and only if you select the whole area of the plot.

推荐答案

我有类似的问题。我最终解决了这个问题(阅读这篇文章后: https://github.com/rstudio/shiny/issues / 998 )通过不打电话打印的情节,只是返回它。所以:
$ b $

I had a similar problem. I fixed it eventually (after reading this post: https://github.com/rstudio/shiny/issues/998) by NOT calling print on the plot, just returning it. So:

output$plot <- renderPlot({
p <- ggplot(iris,aes_string(x=input$x, y=input$y))+geom_point()+theme_bw()
if(input$color != 'None')
p <- p + aes_string(color=input$color)
#print (p)
p
})

这篇关于R闪亮的dataTableOutput不显示刷新点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆