Bin1DimByGroup: Bin one dimension vector by group

Description Usage Arguments Value

Description

Creates a "melted" dataframe of frequencies and probabilities for binned values

Usage

1
2
Bin1DimByGroup(df, var, group, breaks, style, n, midpoints, melt,
  signif, ...)

Arguments

df

Dataframe with 2 columns.

var

Column name of variable to bin

group

Column name of group

breaks

Numeric, vector of bin ranges

style

String, any "breaks" type compatible with classInterval(). Default is "pretty".

n

Numeric, number of bins, as used by classInterval(). Default is 5.

midpoints

Logical, whether to use midpoints for labels. Otherwise, ranges are used. Default is TRUE.

melt

Logical, whether not to melt() the data

signif

Integer, the number of digits used in formatting the break numbers. Default is 5.

...

Arguments to be passed to the functions called in each style used by classIntervals()

Value

Two option: If melt = FALSE, returns the original dataframe with mid-points or ranges for the variable (with suffixes "_mid" or "_bin"). If melt = TRUE, a table of frequencies ("freq"), and densitities ("dens") for each group if "group" parameter is used.


Blakemassey/baear documentation built on Dec. 25, 2021, 9:48 a.m.