0
output$boxPlot <- renderPlot({
    boxplot(input$fileSelect$input$cateSelect, main = "Box plot", ylab = "KJ")
  })

I am doing a interface that the user can select which file and which column of the data they want to plot. I was using a if condition to solve this issue but is there any better way to solve this?

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
  • 2
    What is the actual structure of `input$fileSelect`? As far as I know, there is no input that directly returns a data.frame. It would help immensely if you included a reproducible example. – Mark Peterson Oct 05 '16 at 15:36
  • This examples should help: http://shiny.rstudio.com/gallery/kmeans-example.html , http://shiny.rstudio.com/gallery/widgets.html – user5029763 Oct 05 '16 at 19:54

1 Answers1

1

Do you mean something like this? (assuming that input$fileSelect is a data object and input$cateSelect is a character)

input$fileSelect[[input$cateSelect]]
nilsole
  • 1,663
  • 2
  • 12
  • 28
  • Hi Nilsole, I have two inputs, one the named as fileSelect for a data frame file and the other one is named as cateSelect (column name stored in 'characters'). I tried your way but "subscript out of bounds" is the error message. Many thanks for your solution. – user3378056 Oct 05 '16 at 15:24
  • 1
    Well, the idea is to treat all inputs separately. `input$cateSelect` is different from `input$fileSelect`, that is why you cannot and should not concatenate them by dollar signs. Without having more information about your app, I cannot give you any more advice. – nilsole Oct 05 '16 at 15:36