R for
Authoring!!

OOH Session #53…
…gettin’ Figgie with it!!!

Open Office Hours
(February 04, 2025)

  • Recap session #52       ↔︎️
  • Focal issue(s):
    • polling via : Part IV
  • Shared problem-solving

Recap of Session #52:

Polling via Surveydown – Part III…

…the Shiny element:

---
echo: false
warning: false
theme: [league, weekly.scss]       ## night & league
---

``{r, echo=FALSE}
library(surveydown)
``

![](https://upload.wikimedia.org/wikipedia/en/thumb/e/e4/Woody_Woodpecker.svg/1200px-Woody_Woodpecker.svg.png){.absolute height="100"}

::: {#welcome .sd-page}
# Welcome to our survey!

$I_i(\theta)=a^{2}_iP_i(\theta)Q_i(\theta)$

[This is a simple demonstration of a `surveydown` survey. It has two pages with one question on each page.]{.kulas3}

Here is a basic "multiple choice" question, created using `type = 'mc'` inside the `sd_question()` function:

``{r}
#| echo: false

sd_question(
  type  = 'mc',
  id    = 'penguins',
  label = "$I_i(\\theta)=a^{2}_iP_i(\\theta)Q_i(\\theta)$",
  option = c(
    'Adélie'       = 'adelie',
    'Chinstrap'    = 'chinstrap',
    'Chilly Willy' = "chilly",
    'Downy WP'     = 'woody',
    "Gentoo"       = 'gentoo'
  )
)
``

You need to insert next buttons with `sd_next()` and set the `next_page` argument to the name of the page you want to go to next.

``{r}
sd_next(next_page = 'page2')
``
:::

::: {#page2 .sd-page}
This is another page in your survey.

{surveydown} supports many types of questions. For example, here is a simple `text` type question:

``{r}
sd_question(
  type  = "text",
  id    = "silly_word",
  label = "Write a silly word here:"
)

sd_next(next_page = 'end')
``

:::

``{r}
sd_question(
  type  = 'slider',
  id    = 'climate_care',
  label = "To what extent do you believe human-caused climate change is real?",
  option = c(
    "Don't Believe"    = "dont_believe",
    "Somewhat Believe" = "somewhat",
    "Neutral"          = "neutral",
    "Believe"          = "believe",
    "Strongly Believe" = "strongly_believe"
  )
)
``


``{r}
sd_question(
  type   = 'mc_buttons',
  id     = 'fruit',
  label  = "Which fruit do you prefer most from this list?",
  option = c(
    "Apple"      = "apple",
    "Banana"     = "banana",
    "Pear"       = "pear",
    "Strawberry" = "strawberry",
    "Grape"      = "grape",
    "Mango"      = "mango",
    "Watermelon" = "watermelon"
  )
)
``

::: {#end .sd-page}
## End

This it the last page in the survey.

``{r}
sd_close("Exit Survey")
``
:::

# remotes::install_github("surveydown-dev/surveydown", force = TRUE)
library(surveydown)

# Database setup

# surveydown stores data on a database that you define at https://supabase.com/
# To connect to a database, update the sd_database() function with details
# from your supabase database. For this demo, we set ignore = TRUE, which will
# ignore the settings and won't attempt to connect to the database. This is
# helpful for local testing if you don't want to record testing data in the
# database table. See the documentation for details:
# https://surveydown.org/store-data

db <- sd_database(
  host   = "",
  dbname = "",
  port   = "",
  user   = "",
  table  = "",
  ignore = TRUE
)


# Server setup
server <- function(input, output, session) {

  # Define any conditional skip logic here (skip to page if a condition is true)
  sd_skip_if()

  # Define any conditional display logic here (show a question if a condition is true)
  sd_show_if()

  # Database designation and other settings
  sd_server(
    db = db
  )

}

# shinyApp() initiates your app - don't change it
shiny::shinyApp(ui = sd_ui(), server = server)



# viola

Today…

surveydown Part IV – Capturing the data:

Session Info (February 04, 2025) Rendering:

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] fontawesome_0.5.2

loaded via a namespace (and not attached):
 [1] digest_0.6.35     assertthat_0.2.1  lubridate_1.9.3   fastmap_1.1.1    
 [5] xfun_0.44         magrittr_2.0.3    glue_1.7.0        stringr_1.5.1    
 [9] knitr_1.47        htmltools_0.5.8.1 timechange_0.3.0  generics_0.1.3   
[13] rmarkdown_2.27    lifecycle_1.0.4   cli_3.6.2         vctrs_0.6.4      
[17] compiler_4.3.1    purrr_1.0.1       emo_0.0.0.9000    rstudioapi_0.15.0
[21] tools_4.3.1       evaluate_0.24.0   yaml_2.3.8        rlang_1.1.3      
[25] jsonlite_1.8.9    crayon_1.5.2      stringi_1.7.12