cannot coerce type ‘closure’ to vector of type ‘character’

The call to datasetInput1 and datasetInput2 in the two last lines is the reason of the error.

You should instead call datasetInput1() and datasetInput2(). Otherwise R tries to convert the function to char. It should be:

#Debug print value of sting being passed
output$testvar = renderText(print(datasetInput1()))

# Plot
output$myplot = renderPlot({myplotfunct(iris, datasetInput1(), datasetInput2())})

The () allows you to get the value of the reactive element rather than interact with the reactive element itself. This is a pretty fundamental concept with Shiny and if that’s not something you are yet familiar yet, perhaps revisit the shiny tutotial

Just by adding the (), the error disappears as you can see below:

Leave a Comment