coltypeServer <- function(id, data) {
moduleServer(id, function(input, output, session) {
# (OPTIONAL)
# I just want to see the col types available in the data to explore
# Listing all valid col types in the data()
col_type_options <- reactive({
sapply(data(), function(x){
if(is.numeric(x)) return("numeric")
if(is.character(x)) return("character")
if(is.factor(x)) return("factor")
}) |>
unique()
})
# Update based on available available columns
observeEvent(col_type_options(),{
updateSelectInput(session, "col_type", choices = col_type_options())
})
# (NEEDED PART)
# Selecting function to return
reactive({
switch(input$col_type,
"numeric" = is.numeric,
"character" = is.character,
"factor" = is.factor)
})
}
)
}