File: Tapply.R

package info (click to toggle)
car 3.1-5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496 kB
  • sloc: makefile: 2
file content (8 lines) | stat: -rw-r--r-- 383 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
Tapply <- function(formula, fun, data, na.action=na.pass, ..., targs=list()){
  yx <- if (missing(data)) model.frame(formula, na.action=na.action)
    else model.frame(formula, data=data, na.action=na.action)
  if (ncol(yx) < 2) stop("fewer than two variables")
  targs[c("X", "INDEX", "FUN")] <- list(yx[, 1], yx[, -1], fun)
  targs <- c(targs, list(...))
  do.call(tapply, targs)
}