Using R Shiny to create web surveys, display instant feedback, and store data on Google Drive

How does your score compare to others?", xlab = "Scores", yaxt='n', ylab = "") abline(v=((input$neur1 + (8 – input$neur2))/2), col="blue") text(( (input$neur1 + (8 – input$neur2))/2), 0.

1, "Your Score", col = "red") })output$hn <- renderText({ 'High: This dimension relates to one’s emotional stability and degree of negative emotions.

People that score high on neuroticism often experience emotional instability and negative emotions.

Traits include being moody and tense.

A person who is high in neuroticism has a tendency to easily experience negative emotions.

' })output$ln <- renderText({ "Low: On the other end of the section, people who score low in neuroticism experience more emotional stability.

Emotional stability refers to a person's ability to remain stable and balanced.

They tend to experience negative emotions less easily and handle stress well.

" }) }) After they press submit, they will see where they fall on a normal distribution curve.

Lastly, we need to tell the server to save the inputs after the user presses submit using reactive().

We then use observeEvent() to add the results to our Google Sheet when the user presses submit.

#store the results Results <- reactive(c( input$open1, input$open2, input$consc1, input$consc2, input$extra1, input$extra2, input$agree1, input$agree2, input$neur1, input$neur2, Sys.

time() )) #This will add the new row at the bottom of the dataset in Google Sheets.

observeEvent(input$submit, { Data <- Data %>% gs_add_row(ws = "Data", input = Results()) } ) }shinyApp(ui = ui, server = server)If you want to conduct multiple surveys on the same website, you might consider taking advantage of Shiny’s dashboards.

Check out my friend Conal’s code that uses dashboards.

.. More details

Leave a Reply