App 2: Select data (UI)

Allows the user to select a dataset after confirming if the data is data.frame (filter = is.data.frame) or a matrix (filter = is.matrix)

limit the options to built-in datasets that are either data frames

datasetInput <- function(id, filter = NULL) {
  names <- ls("package:datasets")
  if (!is.null(filter)) {
    data <- lapply(names, get, "package:datasets")
    names <- names[vapply(data, filter, logical(1))]
  }
  
  selectInput(NS(id, "dataset"), "Pick a dataset", choices = names)
}