-
-
Save jcheng5/4050398 to your computer and use it in GitHub Desktop.
shinyServer(function(input, output) { | |
output$filetable <- reactiveTable(function() { | |
if (is.null(input$files)) { | |
# User has not uploaded a file yet | |
return(NULL) | |
} | |
input$files | |
}) | |
}) |
shinyUI(pageWithSidebar( | |
headerPanel("File input test"), | |
sidebarPanel( | |
fileInput("files", "File data", multiple=TRUE) | |
), | |
mainPanel( | |
tableOutput("filetable") | |
) | |
)) |
All's great, but where and how does the file gets stored when it is uploaded ?
Thank you,
Apsara
I'm running my app locally and can't seem to do a multi-select for files when I specify "multiple=TRUE". I'm on Mac OS Yosemite. If it's local, don't see how my web browser figures into this. Has anyone else had this problem? I tried shift-clicking, command-clicking, command-A, and nothing works.
What about if i don't wanna return all the file informations but just the filename. Like for example '/User/Documents/.../filename' the output would look like 'filename'
Dear,
I am new to R-shiny, Can you please help me "how to create a graph using the file which user loaded manually through fileinput function.?
Basically i would like to access the variable from the file loaded by user and create a graph
I am adding a bit of information to this page, since it took me 20 minutes to figure out which is stupid I know, it probably will take someone else it as well.
Most people, like me, will actually want to use the file. When you upload, you do not upload the file but a group of strings, this is what you see when you use the code above. Using the 'datapath' column you are able to use the normal ways to get your data, e.g. read.csv()
Seeing the post linked below made me realize this, using the line:
inFile <- input$files
you get the uploaded data (note this does not contain the file yet) in a data.frame. If you use
dataset<-read.csv(inFile$datapath, header=T, stringsAsFactors =F)
you actually get the data you want in the variable 'dataset'. The variable inFile$datapath contains the path to the file. Now you have the data, play around with it! Using the normal code for the UI you should see your table.
Might be redundant, but since this is one of the first hits on google, I guess it won't hurt.
Links:
https://groups.google.com/forum/?fromgroups=#!topic/shiny-discuss/rQMyQR7gOQk