I am currently trying to teach myself shiny, and am having a little trouble. I want to make an app that has a menu for which dataset the user would like to plot from, followed by another menu for which variable they would like to plot (against the date column)
I have managed to get the reactive menus working, but i am struggling to work out how to 'call' the selected dataset. I have read a lot of posts (e.g 1,2) but none seem to deal with the multiple dataset problem.
My code currently looks like this, with my issues being on the last few lines (how do I get to the mydata within outVar()?!?).
If anyone could point me in the right direction that would be great!
library(shiny)
library(ggplot2)
datafiles<-c("Data/try2.txt","Data/Poland.txt","Data/Romania.txt","Data/Hungary.txt","Data/KHR.txt")
runApp(list(
ui = bootstrapPage(
selectInput('dataset', 'Choose Dataset', datafiles),
selectInput('columns', 'Columns', ""),
plotOutput('graph')
),
server = function(input, output, session){
outVar = reactive({
mydata = read.table(paste0(input$dataset), sep = '\t', header=TRUE)
names(mydata)
})
observe({
updateSelectInput(session, "columns",
choices = outVar()
)})
output$graph<-renderPlot({data<- outVar$mydata
plot(data$Date,data$paste0(input$columns))})
}
))
shinyApp(ui=ui, server=server)