Williams86
Williams86

Reputation: 321

How can I pass a line of code in textInput in R shiny?

I want to pass a line of code in textInput function, like suppose I write list(a = c("b", "c")) in textInput. But textInput would take it as a character string.

Is there any way to do it?

Upvotes: 2

Views: 41

Answers (1)

Ian Campbell
Ian Campbell

Reputation: 24790

You can use eval and parse from base R. Please note that it can be dangerous to evaluate user defined code, so think twice.

string <- 'list(a = c("b", "c"))'
eval(parse(text = string))
#$a
#[1] "b" "c"

Upvotes: 1

Related Questions