Chon
Chon

Reputation: 3

R Shiny - parametrize variable names

I need to parametrize variable names associated to existing variables.

For example:

I have n existing Shiny inputs:

input$input1, ..., input$inputn

How can I use those variables in a loop?

listOfEl <- list()

for(i in 1:n){
    listOfEl[[i]] <- input$input n°i # what's the right R syntax for  'input$input n°i' ?
}

Upvotes: 0

Views: 122

Answers (1)

DeveauP
DeveauP

Reputation: 1237

Try:

eval(parse(text = paste("input$input",i,sep="")))

Upvotes: 1

Related Questions