Created
March 25, 2014 21:07
-
-
Save casunlight/9771411 to your computer and use it in GitHub Desktop.
vivian_shiny_intro_meetup_case_study
This file contains 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
# this solution is contributed by Jay Grossman who attended that intro session! Good job, Jay! | |
# I asked everyone to creat a app which could upload csv data and build linear regression model | |
shinyServer(function(input, output) { | |
#output$contents <- renderTable({ | |
# input$file1 will be NULL initially. After the user selects and uploads a | |
# file, it will be a data frame with 'name', 'size', 'type', and 'datapath' | |
# columns. The 'datapath' column will contain the local filenames where the | |
# data can be found. | |
# inFile <- input$file1 | |
#if (is.null(inFile)) | |
# return(NULL) | |
#csv <- read.csv(inFile$datapath, header=input$header, sep=input$sep, quote=input$quote) | |
#summary(lm(speed~dist,data=csv)) | |
# }) | |
output$summary <- renderPrint({ | |
# input$file1 will be NULL initially. After the user selects and uploads a | |
# file, it will be a data frame with 'name', 'size', 'type', and 'datapath' | |
# columns. The 'datapath' column will contain the local filenames where the | |
# data can be found. | |
inFile <- input$file1 | |
if (is.null(inFile)) | |
return(NULL) | |
csv <- read.csv(inFile$datapath, header=input$header, sep=input$sep, quote=input$quote) | |
summary(lm(speed~dist,data=csv)) | |
}) | |
output$view <- renderPlot({ | |
# input$file1 will be NULL initially. After the user selects and uploads a | |
# file, it will be a data frame with 'name', 'size', 'type', and 'datapath' | |
# columns. The 'datapath' column will contain the local filenames where the | |
# data can be found. | |
inFile <- input$file1 | |
if (is.null(inFile)) | |
return(NULL) | |
csv <- read.csv(inFile$datapath, header=input$header, sep=input$sep, quote=input$quote) | |
plot(lm(speed~dist,data=csv)) | |
}) | |
}) |
This file contains 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
# this solution is contributed by Jay Grossman who attended that intro session! Good job, Jay! | |
# I asked everyone to creat a app which could upload csv data and build linear regression model | |
shinyUI(pageWithSidebar( | |
headerPanel("CSV Viewer"), | |
sidebarPanel( | |
fileInput('file1', 'Choose CSV File', | |
accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')), | |
tags$hr(), | |
checkboxInput('header', 'Header', TRUE), | |
radioButtons('sep', 'Separator', | |
c(Comma=',', | |
Semicolon=';', | |
Tab='\t'), | |
'Comma'), | |
radioButtons('quote', 'Quote', | |
c(None='', | |
'Double Quote'='"', | |
'Single Quote'="'"), | |
'Double Quote') | |
), | |
# mainPanel( | |
# tableOutput('contents') | |
#) | |
mainPanel( | |
verbatimTextOutput("summary"), | |
plotOutput("view") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment