I'm stumped over what I think should be a simple issue. Suppose I have a function, myFunction, that has an argument that is a character vector. Something like:
myFunction <- function(label = NULL){
x <- runif(10)
y <- runif(length(x))
z <- ifelse(x < y, label[1], label[2])
data.frame(x,y,z)
}
and in the R interpreter it yields the following expected result
myFunction(label = c('Hello', 'Goodbye'))
In shiny, how can I properly use textInput to also pass in a character vector equivalent to
c('Hello', 'Goodbye')
Entering those values into the text input box as a string is not giving the expected results in my reproducible code below.
ui <- fluidPage(
textInput("label", "Enter Labels", ""),
verbatimTextOutput("result")
)
server <- function(input, output) {
result <- reactive({
myFunction(label = input$label)
})
output$result <- renderPrint({
result()
})
}
shinyApp(ui, server)
Note, I can easily use a selectInput in this example, but those labels are arbitrary and can take anything the user would think of.
Thank you