Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

xf

Methods that apply a function across a levels of one or more factors


Description

Methods that apply a function across a levels of one or more factors. It works like aggregate but returns a table instead. It also has a useNA options that adds NA as a level before applying the function.

Usage

xf(formula, data, FUN, ..., subset, na.action = na.omit, useNA = FALSE, addmargins = TRUE)

Arguments

formula

Formula defining the variables. On the left is the variable we are applying the function to, on the right, variables defining levels of the tables

data

Data.frame containing the variables

FUN

The function to apply to each subset of data

...

extra parameters to FUN

subset

Vectors defining a subset of data.frame (see help(aggregate)).

na.action

Action functions to deal with NA in data file

useNA

Make NA a level of the factors (if any)

addmargins

Add function applied to the margins of each category

Value

xf returns an object "xf" that behaves like a table with all associated methods.

Author(s)

Charles-Édouard Giguère

Examples

res <- xf(Sepal.Length~Species,iris,mean)
barplot(res)

CUFF

Charles's Utility Function using Formula

v1.7
GPL (>= 2)
Authors
Charles-Édouard Giguère
Initial release
2020-09-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.