observe updateSelectInput - . , csv :
Df1 <- data.frame(
x=1:5,
y=2*(1:5),
z=3*(1:5))
Df2 <- data.frame(
a=6:10,
b=2*(6:10),
c=3*(6:10),
d=letters[1:5],
stringsAsFactors=F)
write.csv(Df1,file="~/tempfiles/Df1.csv",row.names=F)
write.csv(Df2,file="~/tempfiles/Df2.csv",row.names=F)
ui.R:
library(shiny)
shinyUI(fluidPage(
titlePanel("My R Shiny App"),
sidebarPanel(
fileInput(
'file',
'Choose file to upload.'
),
selectInput(
"y_input",
label = h5("Select Time Series/Response Variable"),
""
)
)
))
server.R:
library(shiny)
shinyServer(function(input, output, session) {
inFile <- reactive({
if (is.null(input$file)) {
return(NULL)
} else {
input$file
}
})
myData <- reactive({
if (is.null(inFile())) {
return(NULL)
} else {
read.csv(inFile()$datapath)
}
})
observe({
updateSelectInput(
session,
"y_input",
choices=names(myData()))
})
})
global.R:
myData <- NULL
, , :

