Created
May 14, 2015 12:39
-
-
Save cdeterman/a41cceadffa7907c505e to your computer and use it in GitHub Desktop.
SO 30177053
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(tools) | |
library(XLConnect) | |
shinyServer(function(input, output){ | |
filedata <- reactive({ | |
infile <- input$templatedfile | |
if(is.null(infile)){ | |
return(NULL) | |
} | |
ext <- file_ext(infile$name) | |
importedfile <- | |
switch(ext, | |
csv = read.csv(infile$datapath, stringsAsFactors=FALSE), | |
xlsx = , xls = readWorksheetFromFile(infile$datapath, | |
sheet=1, | |
check.names=FALSE), | |
stop("file extension not recognized")) | |
}) | |
output$mytable <- renderTable({ | |
filedata() | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI( | |
pageWithSidebar( | |
headerPanel("Importing CSV and XLSX files"), | |
sidebarPanel( | |
p("Demo Page"), | |
fileInput("templatedfile", label=h3("Please submit file")) | |
), | |
mainPanel( | |
tableOutput("mytable") | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment