-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
49 lines (39 loc) · 1.68 KB
/
app.R
File metadata and controls
49 lines (39 loc) · 1.68 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
49
# 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.
# For this demo, we set ignore = TRUE in the following code, which will ignore
# the connection settings and won't attempt to connect to the database. This is
# helpful if you don't want to record testing data in the database table while
# doing local testing. Once you're ready to collect survey responses, set
# ignore = FALSE or just delete this argument.
db <- sd_db_connect(ignore = TRUE)
# 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)