Skip to content

Reactive Labels and options depending on previous answers #117

Closed Answered by jhelvy
StefanMunnes asked this question in Q&A
Discussion options

You must be logged in to vote

Btw, here's another way to define the server function in the app.R file:

server <- function(input, output, session) {

  observe({
    date_type <- input$date_type

    # Define the pref_type based on date_type
    pref_type <- "feminity" # Default type
    if (length(date_type) > 0) {
      if (date_type == "men") { pref_type <- "masculinity" }
    }

    # Make the question label and options
    pref_label <-glue::glue(
      "Since you are interested in {date_type}, do you like {pref_type}?"
    )
    pref_options <- c('yes', 'no')
    names(pref_options)[1] <- glue::glue("Yes, I like {pref_type}")
    names(pref_options)[2] <- glue::glue("No, I like {pref_type}")

    # Make the question

Replies: 7 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@StefanMunnes
Comment options

@jhelvy
Comment options

@jhelvy
Comment options

Answer selected by StefanMunnes
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants