I am trying to manipulate pasted data inside a shiny app. Here I tried to add a column as I would normally in R. But I get error message: Warning: Error in UseMethod: no applicable method for 'mutate' applied to an object of class "c('reactive.event', 'reactiveExpr', 'reactive', 'function')"
It makes it sound like I’m trying to manipulate a reactive.event
object, so how do I manipulate the data.frame
? I thought the output of read_clip_tbl()
was a dataframe?
library(dplyr)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
actionButton("clip1", "Read from clipboard")
),
dashboardBody(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tableOutput("table1")
)
)
server <- function(input, output, session) {
table1 <- eventReactive(input$clip1, {
read_clip_tbl()
table1 %>% mutate(fourth = table1$first + table1$second)
})
output$table1<- renderTable({
req(table1())
table1()
})
}
shinyApp(ui, server)