depreciated/sapply_df.R

#' Applying multiple functions to data.frame.
#' Extracted from https://www.r-bloggers.com/applying-multiple-functions-to-data-frame/
#' @param ...: Data frame, functions names or unnamed functions.
#' 

sapply_df <- function(...) {
  arglist <- match.call(expand.dots = FALSE)$...
  var.names <- sapply(arglist, deparse)
  has.name <- (names(arglist) != "")
  var.names[has.name] <- names(arglist)[has.name]
  arglist <- lapply(arglist, eval.parent, n = 2)
  x <- arglist[[1]]
  arglist[[1]] <- NULL
  result <- sapply(arglist, function (FUN, x) sapply(x, FUN), x)
  colnames(result) <- var.names[-1]
  return(result)
}
diegogarcilazo/myutilities documentation built on Jan. 4, 2024, 2:11 p.m.