【发布时间】:2019-12-13 19:32:13
【问题描述】:
我正在尝试过滤数据框,然后对数据进行一些简单的 ggplots。我尝试利用 Shiny 文档上的 R studio 示例以及有关该主题的以下 SO 帖子:
Reactively filtering/subsetting a data frame in shiny
这是我的代码。
---
title: "Shiny Filter Test"
author: "Novice"
date: "12/13/2019"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
library(shiny)
inputPanel(
selectInput("n_break", label = "Number of bins:",
choices = c(10, 20, 35, 50), selected = 10)
)
cdat <- reactive({
data <- tibble(x = c(10,20,35), y = c("a","b","c"))
data %>%
filter(x %in% input$n_break)
output$table <- DT::renderDT({
cdat()
}, options = list(scrollX = TRUE))
})
```
谁能指出我哪里出错了?当我运行代码时,我得到了我的下拉框,但仅此而已。没有错误。只是没有过滤的数据表。
谢谢。
【问题讨论】: