binData: binData

View source: R/binData.R

binDataR Documentation

binData

Description

Bins each variable in data in bins Bins. It can return a data frame (out="data.frame"), a table with the counts (out="table"), or a table converted to a data frame with an additional variable Freq. The values can be either the bin mids (val="mids") or the bin numbers (val="interval"). If possible all variables contain an attribute breaks with breaks used.

Usage

binData(
  data,
  bins,
  out = c("data.frame", "table", "binned"),
  val = c("mid", "interval"),
  pretty = TRUE,
  numeric = TRUE
)

Arguments

data

object: a data.frame or object that can be converted to a data frame with variables to bin

bins

integer: number of bins, will be recycled if necessary

out

character: output type, either "data.frame", "table", or "binned"

val

character: values for outer, eiter "mids" (interval centers), or "interval (interval number)

pretty

logical: should be base::pretty used or minimum and maximum (default: TRUE)

numeric

logical: return output a factor or as numeric (default: TRUE)

Value

a data frame or table with the results

Examples

df <- data.frame(x=runif(25), y=runif(25))
binData(df, 5, 'data.frame')
binData(df, 5, 'table')
binData(df, 5, 'binned')

sigbertklinke/smvgraph documentation built on Dec. 10, 2022, 9:13 a.m.