Learn R Programming

⚠️There's a newer version (0.10.1) of this package.Take me there.

surveydown

Note: This site only documents the {surveydown} R package - visit our main site at surveydown.org for more information!

surveydown is a flexible, open-source platform for making surveys with R, Quarto, Shiny, and Supabase.

The basic concept is:

  1. Design your survey as a Quarto document using markdown and R code.
  2. Convert your survey into a Shiny app that can be hosted online and sent to respondents.
  3. Store your survey responses in a Supabase database (or any Postgres database).

The {surveydown} R package provides functions to bring this all together.

See the documentation to get started making your own surveydown survey!

Installation

Install R & Quarto

We also recommend working with an IDE that has good support for R, Quarto, and Shiny. RStudio is great, and we also like VSCode and Positron.

Install the {surveydown} R package

You can install {surveydown} from CRAN in your R console:

install.packages("surveydown")

or you can install the development version from GitHub:

# install.packages("pak")
pak::pak('surveydown-dev/surveydown')

Load the package with:

library(surveydown)

You can also check which version you have installed:

surveydown::sd_version()

Background & Motivation

Most survey platforms (e.g., Google forms, Qualtrics, etc.) use drag-and-drop interfaces to design surveys, making version control and collaboration with others difficult. They’re also not reproducible (others cannot easily reproduce a survey made on these platforms), and many require a paid subscription or license to use.

The surveydown package was designed to address these problems. As an open-source, markdown-based platform, all survey content is defined with plain text (markdown and R code) in a survey.qmd file and an app.R file that renders your survey into a Shiny app that can be hosted online. This makes your survey easy to reproduce, share, and version control with common tools like Git. The survey data collected is also owned by the survey designer in a separate Postgres database (we recommend Supabase as a free and open-source database provider).

If you’re curious where this whole idea came from, check out this blog post, which outlines more on the general idea and the motivation for it. The post is now outdated in terms of the overall package design, but it provides something of an origin story and some of the motivation for developing this project.

TODO List

This is a running list of things we’re working on / have already added to the project:

  • show_if (conditionally display question)
  • skip_if (conditionally skip to page)
  • Set defaults for questions to not have any choices selected on launch.
  • Ability to embed markdown inside choice options (like mc buttons in formr)
  • Option for ignore = TRUE setting (database connection is ignored)
  • Automatically include timestamps on each page and question interaction in the data
  • Option to start at a designated page, e.g. start_page = 'page_name'
  • A show_all_pages = TRUE argument to show all the pages and hidden questions when launched (e.g. to be able to print out the entire survey text). Could also be a sd_print_survey() function to print it to pdf.
  • Set up SCSS to be compatible with Quarto-supported bootstrap themes.
  • Include an optional progress bar.
  • Include input checks for skip_if and show_if (question_id exists, and data frame names are correct)
  • Required questions: post a popup if a question is required before allowing next button.
  • Add a sd_get_data() function so the survey designer can obtain the current survey results from inside the app: https://shinysurveys.jdtrat.com/articles/get-survey-data.html
  • Ability to pass url parameters, e.g. for tracking users.
  • Ability to redirect users to another url.
  • Leverage cookies so users who close the browser can start back where they left off.
  • Admin page w/password to preview / download data (see https://github.com/daattali/shinyforms)
  • Form validation: Make sure the user inputs the correct type depending on the question type. (see https://shiny.posit.co/r/reference/shiny/0.14/validate.html)
  • Question types:
    • Multiple choice (single choice)
    • Multiple choice (multiple choices)
    • Select
    • Text
    • Numeric
    • Multiple choice (button…like formr mc_button)
    • Text area
    • Date
    • Slider
    • Matrix
    • Best worst

Resources / other related examples:

License Information

Citation Information

If you use this package for in a publication, please cite it! You can get the citation by typing citation("surveydown") into R:

citation("surveydown")

Copy Link

Version

Install

install.packages('surveydown')

Monthly Downloads

514

Version

0.5.0

License

MIT + file LICENSE

Maintainer

John Helveston

Last Published

November 25th, 2024

Functions in surveydown (0.5.0)

sd_show_password

Show the Saved Survey Password
sd_set_password

Set password for surveydown survey
sd_setup

Required Set Up Function
sd_show_if

Define show conditions for survey questions
sd_skip_if

Define skip conditions for survey pages
sd_store_value

Store a value in the survey data
sd_ui

Create the UI for a surveydown survey
sd_version

Check Surveydown Version
sd_add_page

Add a Page Template to the Current Document
sd_completion_code

Generate a Random Completion Code
sd_close

Create a 'Close' Button to Exit the Survey
sd_display_value

Display the value of a survey question
sd_copy_value

Create a copy of a value
sd_display_question

Create a placeholder for a reactive survey question
sd_next

Create a 'Next' Button for Page Navigation
sd_output

Output Function for Displaying reactive objects and values
sd_question

Create a survey question
sd_redirect

Create a Redirect Element for 'shiny' Applications
sd_create_survey

Create a new survey template
sd_server

Server logic for a surveydown survey
sd_get_url_pars

Get URL Parameters in a 'shiny' Application
sd_get_data

Fetch data from a database table with automatic reactivity detection
sd_add_question

Add a Question Template to the Current Document
sd_include_folder

Include a folder to the 'shiny' resource path
sd_database

Connect to a 'PostgreSQL' Database with Automatic Cleanup
sd_create_translations

Create a translations template file
sd_is_answered

Check if a question is answered