将输入传递给tidyverse在闪亮的应用程序中汇总

时间:2019-02-08 22:08:55

标签: r shiny dplyr

我在为闪亮的应用程序中的选定列计算分组摘要统计信息时遇到麻烦。 tidyverse摘要中使用的基本R摘要函数似乎无法识别来自我闪亮的应用程序的字符串输入。我想要一张最小值,最大值,均值,sd和计数的表格。

library(shiny)
library(tidyverse)
library(DT)

ui <- fluidPage(
  selectInput("summarycol", "Summary Stats For (Select One):", choices = c("mpg", "hp")),
  DT::dataTableOutput("table")
)

server <- function(input, output) {
 table <- reactive({
   mtcars %>% group_by(cyl) %>% summarize(mean = mean(input$summarycol))
 })
 output$table <- DT::renderDataTable(table())
}

shinyApp(ui = ui, server = server)

我明白了

Warning in mean.default(input$summarycol) :
  argument is not numeric or logical: returning NA

我还尝试在均值的输入变量之前插入!!,但这给出了

Warning in mean.default("mpg") :
  argument is not numeric or logical: returning NA

是否可以删除引号并使基本摘要功能识别所选列?

0 个答案:

没有答案