split_by: Split a Vector

Description Usage Arguments Examples

View source: R/split_by.R

Description

A vector can be split by median, mean, a value, or by fivenum. It returns a factor vector.

Usage

1
2
3
split_by(x, split = NULL,
         factors = NULL,
         split.mode = c("minor", "minor.equal", "major.equal"))

Arguments

x

a numeric vector containing the values whose split is to be computed.

split

defines the method by which the split has to be operated. It can be a numeric value or a character indicating "mean", median, or "fivenum", respectively if the split is on the mean (see "mean"), the median (see "median"), or by the fivenum (see "fivenum").

factors

a character vector containing the two factor names (first is the lower) for the split. It does not work for fivenum that automatically provides factor names. If NULL, factors are automatically coded as "low." and "high." with the vector name attached

split.mode

the modality by which values are split: default is "minor equal", (i.e., "<="). Other modalities are "minor" ("<") and "major.equal" (">="). It does not work for fivenum that automatically provides the split by the function "symnum".

Examples

1
2
3
4
5
split_by(mtcars$mpg, 'median')
split_by(mtcars$mpg, 'mean')
split_by(mtcars$mpg, 30)
split_by(mtcars$mpg, split = 'fivenum')
split_by(mtcars$mpg, factors = c('belowMedian', 'aboveMedian'))

alemiani/explora documentation built on May 28, 2019, 4:54 p.m.