r - shiny: plot a graph from source file dependent on input -


so trying out shiny, , have problem.

what want selectinput can select different option , graph. these different graphs ggplot2 graphs created in source file. graphs have called. not seem figure out how that. graphs ggplot2 graphs , fine, load perfectly, assume that not problem.

i want have text output depends on selectinput.

so here server script:

shinyserver(   function(input, output) {     output$map <- renderplot({       plot <- switch(input$activity,                      "" = null,                     "act1" = plot1,                     "act2" = plot2,                     "act3" = plot3,                     "act4" = plot4,                     "act5" = plot5,                     "act6" = plot6)      plot    }),    output$text1 <- rendertext({       text <- switch(input$activiteit,              "" = null,             "act1" = paste("blabla"),             "act2" = paste("blabla2"),             "act3" = paste("blabla3"),             "act4" = paste("blabla4"),             "act5" = paste("blabla5"),             "act6" = paste("blabla6")             )      text    })   }  ) 

one thing not have load source file. load in main file run app. can understand have load in server file.

however not problem because text not showing in shiny output. must wrong code. ui script gives right output, not problem. hope can me.

.hi, dont need comma between 2 outputs in server.r , dont need "" = null, in switch. try example :

## ui.r shinyui(fluidpage( selectinput(inputid = "activiteit", label = "", choices = c("", paste0("act", 1:6))), h2("your text"), textoutput(outputid = "text1"), h2("your graph"), plotoutput(outputid = "map") ))  ## server.r shinyserver( function(input, output) {    output$map <- renderplot({      p <- switch(input$activiteit,                   "act1" = p1,                  "act2" = p2,                  "act3" = p3,                  "act4" = p4,                  "act5" = p5,                  "act6" = p6)     print(p)   })   # no comma here   output$text1 <- rendertext({     text <- switch(input$activiteit,                   "act1" = paste("blabla"),                  "act2" = paste("blabla2"),                  "act3" = paste("blabla3"),                  "act4" = paste("blabla4"),                  "act5" = paste("blabla5"),                  "act6" = paste("blabla6")   )   return(text)   })    }  )  ## global.r # can source files here library(ggplot2) p1 <- qplot(1:10, rnorm(10), colour = runif(10)) p2 <- qplot(1:20, rnorm(20), colour = runif(20)) p3 <- qplot(1:30, rnorm(30), colour = runif(30)) p4 <- qplot(1:40, rnorm(40), colour = runif(40)) p5 <- qplot(1:50, rnorm(50), colour = runif(50)) p6 <- qplot(1:60, rnorm(60), colour = runif(60)) 

hope helps.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -