shiny reactive output, evaluate input only after first click on actionbutton

Viewed 656

I have a simple shiny app where the user should input comma-separated values into a text input, chose the output and click on a button to convert to an output.

I have followed the advice in Update content on server only after I click action button in Shiny to change the output only when clicking, and it works.

However, only when starting/ opening the app the first time, the field is empty, yet the output seems to try to evaluate the input field.

It is more of a cosmetic problem, because once the user filled something in, this does not recur, but I wonder how I could avoid this...

My app:

library(shiny)

ui <- fluidPage(
  textInput("from", "csv", value = NULL),

  actionButton("run", "Run"),

  textOutput("to")
)

server <- function(input, output, session) {
  list1 <- reactive({
    input$run
    x <- isolate(paste(read.table(text = input$from, sep = ",")))
    x
  })

  output$to <- renderText({
    list1()
  })
}

shinyApp(ui = ui, server = server)

The not-desired output - I would like to get rid of the errors.

enter image description here

1 Answers
Related