-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
48 lines (38 loc) · 1.6 KB
/
Copy pathapp.R
File metadata and controls
48 lines (38 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Package setup ---------------------------------------------------------------
# Install required packages:
# install.packages("pak")
# pak::pak("surveydown-dev/surveydown") # Development version from GitHub
# Load packages
library(surveydown)
# Database setup --------------------------------------------------------------
#
# Details at: https://surveydown.org/docs/storing-data
#
# surveydown stores data on any PostgreSQL database. We recommend
# https://supabase.com/ for a free and easy to use service.
#
# Once you have your database ready, run the following function to store your
# database configuration parameters in a local .env file:
#
# sd_db_config()
#
# Once your parameters are stored, you are ready to connect to your database.
# This template runs in preview mode (set via `mode: preview` in survey.qmd),
# which saves responses locally instead of to a database. To collect real
# responses, run sd_db_config() to store your database credentials, then
# change `mode` to `database` in the survey.qmd YAML header.
db <- sd_db_connect()
# UI setup --------------------------------------------------------------------
ui <- sd_ui()
# Server setup ----------------------------------------------------------------
server <- function(input, output, session) {
# Define any conditional skip logic here (skip to page if a condition is true)
sd_skip_if(
sd_value("skip_to_page") == "end" ~ "end",
sd_value("skip_to_page") == "question_formatting" ~ "question_formatting"
)
# Run surveydown server and define database
sd_server(db = db)
}
# Launch the app
shiny::shinyApp(ui = ui, server = server)