r - 按变量过滤数据帧并输出为闪亮的表格
问题描述
我对 Shiny 输出有点卡住了。我想过滤数据框并将结果输出为表格。数据框是案例的长格式。“变量”是我要过滤的区域:
> str(UZ_COVID19_long_rev0)
'data.frame': 1694 obs. of 3 variables:
$ Date : POSIXct, format: "2020-03-15" "2020-03-16" "2020-03-17" ...
$ variable: Factor w/ 14 levels "Karak_Rep","Andijon",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value : num 0 0 0 0 0 0 0 0 0 0 ...
library(shiny)
tib<-UZ_COVID19_long_rev0
ui = pageWithSidebar(
headerPanel("Selection Panel"),
sidebarPanel(
selectizeInput('region', 'Select region',
choices = c(levels(tib$variable)))
),
mainPanel(
verbatimTextOutput("table")
)
)
server = function(input, output, session)
{
output$table <- renderTable({
tib %>%
filter(variable == input$region)
})
}
shinyApp(ui = ui, server = server)
但我收到一个错误:“找不到对象‘变量’”
我相信代码中存在错误,但无法获取。
解决方案
推荐阅读
- python - 我的 Python 代码关于这个算法有什么问题?
- sql - 每次在 PL/SQL 中执行存储过程时都可以提示吗?
- bash - 在 watch 调用中使用多个 tee 命令重定向
- php - 注意:未定义的偏移量:第 40 行 C:\xampp\htdocs\WebTech Mid Project\registration.php 中的 2
- python - 无法从列表中删除特定元素 [Python]
- java - 使用 Process Builder 执行命令时获得权限被拒绝
- swift - 如何在 RealityKit 中实现广告牌?
- python - 调整另一个网站的网页抓取代码
- javascript - 如何从另一个单文件组件VueJS触发单文件组件中的方法
- javascript - 多个嵌入到一条消息中