R/natural_order.R

Defines functions natural_order

natural_order <- function(data, cols){
  # data should be only a matrix or a data frame at this point
  stopifnot(is.matrix(data) || is.data.frame(data))
  df <- as.data.frame(data)
  if(is.numeric(cols)){
    cols <- paste0("df[[", cols, "]]", collapse = ", ")
  } else {
    cols <- paste0("df[[\"", cols, "\"]]", collapse = ", ")
  }
  eval(str2expression(paste0("order(", cols, ")")))
}

Try the distfreereg package in your browser

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

distfreereg documentation built on April 4, 2025, 12:30 a.m.