Hello!
I am learning Shiny. In my ui am allowing the user to read in 3 files. Here
is a piece of my ui.r code:
sidebarPanel(
fileInput('file1','Select File 1:'),
fileInput('file2','Select File 2:'),
fileInput('fileopt','Select Optional File:'),
actionButton("goButton","RUN")
),
Then I want my server code (below) to do something based on EITHER all 3
files that were read in OR - if the 3rd file was not uploaded - based on
just the first 2 files.
However, it's not working. Maybe what I am doing with myflag is wrong?
Or maybe I am isolating incorrectly at the very bottom?
Thank you so much for any pointers!
Dimitri
shinyServer(function(input,output){
# Drop-down selection box for Input file 1:
renderUI({
fileInput('utils')
})
# Drop-down selection box for Input file 2:
renderUI({
fileInput('attrib')
})
# Drop-down selection box for Input file 3 (optional):
renderUI({
fileInput('test')
})
myflag=1
bigone<-reactive({
inFile1<-input$file1
inFile2<-input$file2
inFile3<-input$fileopt
if (is.null(inFile3)) myflag=0
forout1<-read.csv(inFile1$datapath)
forout2<-read.csv(inFile2$datapath)
if(myflag==1) forout3<-read.csv(inFile3$datapath)
if(myflag==1){
out1<-cbind(forout1,forout2,forout3)
out2<-cbind(forout2,forout1,forout3)
} else {
out1<-cbind(forout1,forout2)
out2<-cbind(forout2,forout1)
}
return(list(out1,out2))
})
# Summary statistics for the moments data frame (for testing purposes):
output$myoutput1<-renderPrint({
input$goButton
# Isolating:
isolate(bigone()$out1)
# bigone()$out1
})
output$myoutput2<-renderPrint({
input$goButton
# Isolating:
isolate(bigone()$out2)
})
})
[[alternative HTML version deleted]]