Sunday 15 July 2012

R shiny - How to transform String into piece of code to use it as input on Server.R? -



R shiny - How to transform String into piece of code to use it as input on Server.R? -

i trying values inputs ids "imp1", "imp2", "imp3",... there's no limit amount of 'imps' cannot done manually. thought create list called "impidlist" gets amount of 'imps' , assign string each entry of list "imp1", "imp2",... problem server.r doesn't utilize string's process inputs uses imp1, or imp2 or imp3... without quotes. happens when to:

impidlist<-for(i in 1:numimp){ impid<-paste("imp",tostring(i)) imps[[i]]<-input$impid }

because impid (3rd line) "imp1", not imp1.

ui.r (...) output$imps<-renderdatatable({ numimp<-(input$num_imp) imps<-list() impidlist<-for(i in 1:numimp){ impid<-paste("imp",tostring(i)) imps[[i]]<-input$impid } }) (...)

if more info needed (or question not in right format...) please vote downwards , @ to the lowest degree something...i kind of need help...

ok, solved it.

server.r uses inputs " input$something " , creates outputs " output$something ".

ui.r displays outputs xoutput("something"), , inputs created in widget as, example:

numericinput({ inputid="imp1", label="blah blah" )}

as had inputs id's "imp1", "imp2", "imp3",... , needed server.r utilize them input$imp1, input$imp2, input$imp3,... (without quotes) used parse within loop. saved inputs in list called "imps", input called "num_imps" got number of numericinputs. code looks like

v_imps<-reactive({ numimp<-(input$num_imp) imps<-list(c("a","b")) for(i in 1:numimp){ impid<-paste("imp",tostring(i),sep = "") imps[[1]][i]<-eval(parse(text = paste("input$",impid,sep = ""))) } imps })

i going set images of i've done have not plenty rep. anyway

r string list shiny quotes

No comments:

Post a Comment