【发布时间】:2020-02-25 21:23:40
【问题描述】:
我想更新一个响应式对象的内容,该对象持有一个小标题以响应按钮按下,但我不知道语法。 here 发布的解决方案包含一个过去可以工作但现在引发错误的解决方案。
以下是我遇到的问题的代表。先运行write.csv(iris, "text.csv")。
library(shiny)
library(tidyverse)
# create the test data first
# write.csv(iris, "text.csv")
server <- shinyServer(function(input, output) {
in_data <- reactive({
inFile <- input$raw
x <- read.csv(inFile$datapath, header=TRUE)
})
subset <- reactive({
subset <- in_data() %>%
filter(Species == "setosa")
})
observeEvent(input$pushme, {
subset()$Sepal.Length[2] <- 2
})
output$theOutput <- renderTable({
subset()
})
})
ui <- shinyUI(
fluidPage(
fileInput('raw', 'Load test.csv'),
actionButton("pushme","Push Me"),
tableOutput('theOutput')
)
)
shinyApp(ui,server)
我的更改值的代码:
subset()$Sepal.Length[2] <- 2
抛出此错误:
Error in <-: invalid (NULL) left side of assignment
以编程方式更改响应式小标题中的值的语法是什么?
【问题讨论】: