Asignar valores numéricos o una cadena de caracteres

Estoy tratando de crear una ShinyApp y espero poder obtener algunos consejos.

Estoy tratando de obtener una tabla de resumen ("Puntuación de resumen") para representar i) el valor mínimo asociado con la entrada del usuario para los botones de opción (por ejemplo, Id037_crit1 e Id038_crit1) o la cadena de texto "NA" si se selecciona una casilla de verificación ( Id039_crit1).

No estoy seguro de cómo cambiar el código de modo que la tabla de resumen muestre el valor mínimo para los botones de opción o la cadena de caracteres si la casilla de verificación está seleccionada. Supongo que hay algún tipo de declaración if-else, pero no puedo hacer que funcione.

library(shinydashboard)
library(shinythemes)
library(shiny)
library(shinyWidgets)
library(DT)
library(tidyverse) 
ui <- fluidPage(
  theme = shinytheme("united"),

  # Application title
  titlePanel("TITLE"),
  sidebarLayout(
    sidebarPanel(
      selectInput("select",
        label = helpText("Select a critera"),
        choices = list("Criteria_1", "Criteria_2"),
        selected = c("NULL")
      )
    ),
    mainPanel(tabsetPanel(
      tabPanel(
        "Criteria", conditionalPanel(h3("Question 1", align = "left"),
          condition = "input.select == 'Criteria_1'",
          prettyRadioButtons(
            inputId = "Id037_crit1",
            label = "Predictions:",
            choices = c(
              "Option 1" = 1,
              "Option 2" = 2,
              "Option 3" = 3
            ),
            inline = TRUE,
            status = "danger",
            fill = TRUE
          ),
        ),
        conditionalPanel(h3("Question 2", align = "left"),
          condition = "input.select == 'Criteria_1'",
          prettyRadioButtons(
            inputId = "Id038_crit1",
            label = "Hypotheses:",
            choices = c(
              "Option 1" = 1,
              "Option 2" = 2,
              "Option 3" = 3
            ),
            inline = TRUE,
            status = "danger",
            fill = TRUE)
        ),
 
conditionalPanel(h3("Or", align = "left"),
                                     condition =  "input.select == 'Criteria_1'",
                                     awesomeCheckbox(
                                       inputId = "Id039_crit1",
                                       label = "NA",
                                       status = "danger")
        ),

        # User side-pannel selection - criteria 2


        conditionalPanel(h3("Question 1", align = "left"),
          condition = "input.select == 'Criteria_2'",
          prettyRadioButtons(
            inputId = "Id040_crit2",
            label = "Methods:",
            choices = c(
              "Option 1" = 1,
              "Option 2" = 2
            ),
            inline = TRUE,
            status = "danger",
            fill = TRUE)),


      # Second Tab --------------------------------------------------------------


      tabPanel(
        "Summary score",
        DTOutput("summary")
      ),
    ))
  )
)

# SERVER ------------------------------------------------------------------


server <- function(input, output) {
  
  calc_min_val <- function(contains) {
    radios_inputid <- str_subset(names(input), contains)
    map_dbl(radios_inputid, ~ as.numeric(input[[.x]])) %>%
      min()
  }
  
  
  summ <- reactive({
    min_values <- c("crit1$", "crit2$") %>%
      map(calc_min_val)
     
    
    
    tibble(
      Lowest_Criteria = c("Specific hypotheses and prediction are provided?", "Predictions regarding the electromagnetic area of 
interest are sufficient?"),
      value = map(min_values, ~.)
    )
  })
  
  
  output$summary <- DT::renderDT({
    datatable(summ())
  })
# Downloadable csv of selected dataset ----
  output$downloadData <- downloadHandler(
    filename = function() {
      paste("DATA", ".csv", sep = "")
    },
    content = function(file) {
      write.csv(datasettable(summ()), file, row.names = FALSE)
    }
  )
}
shinyApp(ui, server)
Answer

Quizás estés buscando esto

summ <- reactive({
      min_values <- c("crit1$", "crit2$") %>%
        map(calc_min_val)
      if (input$Id039_crit1 & input$select == 'Criteria_1') value = "NA" else value = map(min_values, ~.)
      
      tibble(
        Lowest_Criteria = c("Specific hypotheses and prediction are provided?", "Predictions regarding the electromagnetic area of 
interest are sufficient?"),
        value = value
      )
    })