R/clean_input.R

Defines functions clean_input

# -----------------------------------------------------------------------------
# Utility function to convert single-column data frames to vectors,
# and all other data frames to numeric matrices
# -----------------------------------------------------------------------------
clean_input <- function(obj) {
  if (is.data.frame(obj)) {
    if (ncol(obj) == 1) {
      return(obj[[1]])
    } else {
      return(as.matrix(obj))
    }
  }
  return(obj)
}

Try the BMEmapping package in your browser

Any scripts or data that you put into this service are public.

BMEmapping documentation built on July 2, 2025, 9:07 a.m.