【发布时间】:2021-05-01 15:30:09
【问题描述】:
我面临与 rhandsontables 相关的各种操作的挑战,尽管它们对于我正在尝试创建的应用程序来说似乎是无价的。我的第一个挑战是我试图通过从用户输入中过滤原始数据框来更新 rhandsontable,从下拉列表 (selectInput) 中选择。
这是一个简化的可重现示例,它让我得到了我想要的结果,但不是通过我希望的方式:
library(shiny)
library(rhandsontable)
library(tidyverse)
counties = as.factor(c(rep("County1", 2), rep("County2", 2)))
compnames = as.factor(c("comp1", "comp2", "comp3", "comp4"))
properties = 1:4
soilsData <- data.frame(county = counties, compname = compnames, property = properties)
ui <- fluidPage(
selectInput(inputId = "selectCounty", label = h4("Select County"),
choices = counties,
selected = "County1",
multiple = FALSE),
br(),
br(),
rHandsontableOutput('rTable'),
)
server <- function(input, output) {
df1 <- df %>%
filter(county == "County1", compname == "comp1")
datavalues <- reactiveValues(data = df1)
output$rTable <- renderRHandsontable ({
rhandsontable(datavalues$data,
rowHeaders = NULL)
})
}
如何通过选定的 sliderInput 创建那个 df1?
【问题讨论】:
标签: r shiny rhandsontable selectinput