该模块的目标是创建一个根据数据选择器模块的输出而变化的反应性条形图。不幸的是,条形图没有更新。它停留在选定的第一个变量上。
我尝试创建观察者函数来更新条形图,但无济于事。我还尝试将选择器服务器模块嵌套在 barplot 模块中,但收到错误:警告:UseMethod 中的错误:没有适用于“mutate”的方法应用于类“c('reactiveExpr', 'reactive'”的对象, '功能')”
我只需要某种方法来告诉 barplot 模块在输入的数据发生变化时进行更新。
条形图模块:
#UI
barplotUI <- function(id) {
tagList(plotlyOutput(NS(id, "barplot"), height = "300px"))
}
#Server
#' @param data Reactive element from another module: reactive(dplyr::filter(austin_map, var == input$var))
barplotServer <- function(id, data) {
moduleServer(id, function(input, output, session) {
#Data Manipulation
bardata <- reactive({
bar <-
data |>
mutate(
`> 50% People of Color` = if_else(`% people of color` >= 0.5, 1, 0),
`> 50% Low Income` = if_else(`% low-income` >= 0.5, 1, 0) …Run Code Online (Sandbox Code Playgroud)