univariateSummary: Generate a univariate summary table

Description Usage Arguments Value See Also Examples

View source: R/univariateSummary.R

Description

univariateSummary() produces a univariate summary table, evaluating x as the independent variable and y as the dependent variable. It uses the S3 generic function bin to bin the values of x, then per bin, applies FUN to y. The vector x can include missing values but y cannot. When ytype = 1, y must contain only unique (coercable) values of 0 or 1. When ytype = 2, y must have at least 3 distinct values.

Usage

1
univariateSummary(x, y = rep(0, length(x)), ytype = 1, FUN = mean, ...)

Arguments

x

character, factor, logical or numeric vector (independent variable)

y

logical, integer or numeric vector (dependent variable)

ytype

integer value of 1 (binary y) or 2 (continuous y)

FUN

function to be applied to y

...

further arguments passed to bin

Value

A data frame with class "mt_univariateSummary" containing the following columns:

See Also

bin

Examples

1
2
3
4
5
6
7
8
9
# character x, continuous y
z <- univariateSummary(iris$Species, iris$Sepal.Length, ytype = 2)
print(z)
class(z)

# numeric x, logical y, additional arguments to bin()
z <- univariateSummary(mtcars$hp, mtcars$mpg > 15, numBins = 2)
print(z)
class(z)

dnegrey/miscTools documentation built on Sept. 19, 2017, 12:15 a.m.