Last active
December 31, 2015 03:56
-
-
Save dmarcelinobr/1fa48f85ef6bfaa59e1b to your computer and use it in GitHub Desktop.
Simple Shiny survey that pushes data to a Dropbox folder
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
# devtools::install_github("duncantl/ROAuth") | |
# devtools::install_github("karthik/rDrop") | |
library(ROAuth) | |
library(rDrop) | |
load('my_dropbox_credentials.rdata') #credentials object from rDrop instructions | |
shinyServer(function(input, output) { | |
output$Main <- renderUI({ | |
dynamicUi() | |
}) | |
dynamicUi <- reactive({ | |
if(input$Finish == 0L){ | |
return(NULL) | |
} else { | |
if(input$firstname == '') return(stop('Missing First Name input!')) | |
if(input$lastname == '') return(stop('Missing Last Name input!')) | |
got <- c(input$LVMFA, input$Issues, input$Regression, input$GLVM, | |
input$Green, input$Review) | |
if(length(unique(got)) <= 2L){ | |
msg <- paste0(input$firstname, ', your responses contain little to no | |
variability; please think more carefully about your book choices | |
and rate them accordingly.') | |
msg <- gsub('\n', ' ', msg) | |
return(stop(msg)) | |
} | |
ret <- rank(as.numeric(got)) | |
dropbox_save(dropbox_credentials, ret, | |
file=paste0(input$firstname,input$lastname), | |
verbose=FALSE, ext=".Rdata") | |
return(h3('Thank you for completing the form! Your responses have been uploaded sucessfully. | |
It is now safe to close your browser.')) | |
} | |
}) | |
}) |
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
shinyUI(pageWithSidebar( | |
headerPanel('SCS Reading List, 2014-2015'), | |
sidebarPanel( | |
h3(' Please fill in the following:'), | |
textInput(inputId = 'firstname', label = ' First Name:', value =''), | |
textInput(inputId = 'lastname', label = ' Last Name:', value =''), | |
hr(), | |
h5('Upon completion, click the following button to submit your responses.'), | |
actionButton("Finish", "Click Me! I'm the button!"), | |
uiOutput("Main") | |
), | |
mainPanel( | |
h4('Rate the following books for the SCS seminar (1 = Most Wanted, 6 = Least Wanted).'), | |
hr(), | |
sliderInput(inputId = "LVMFA", min = 1, max=6, step = 1, value=3, | |
label = "Latent Variable Models and Factor Analysis: A Unified Approach"), | |
br(),br(), | |
sliderInput(inputId = "Issues", min = 1, max=6, step = 1, value=3, | |
label = " Contemporary Issues in Exploratory Data Mining in the | |
Behavioral Sciences"), | |
br(),br(), | |
sliderInput(inputId = "Regression", min = 1, max=6, step = 1, value=3, | |
label = "Regression Modeling Strategies: With Applications to Linear Models, | |
Logistic Regression, and Survival Analysis"), | |
br(),br(), | |
sliderInput(inputId = "GLVM", min = 1, max=6, step = 1, value=3, | |
label = "Generalized latent variable modeling: Multilevel, longitudinal and | |
structural equation models "), | |
br(),br(), | |
sliderInput(inputId = "Green", min = 1, max=6, step = 1, value=3, | |
label = "Little Green Books"), | |
br(),br(), | |
sliderInput(inputId = "Review", min = 1, max=6, step = 1, value=3, | |
label = "The reviewer's guide to quantitative methods in the social sciences") | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment