binStats: binStats

Description Usage Arguments Details Value Author(s) Examples


bin and calculate mean and for each bin


binStats(.d, bins = 20, xlow = min(.d[, 2], na.rm = TRUE),
  xhigh = max(.d[, 2], na.rm = TRUE), addBin = FALSE)



A data-frame containing at least two columns, the first holding values to partition and summarize and the second the variable used for defining bins. Values from the first will be grouped according to the bins in the second and then a mean and standard deviation will be calculated for each group. Additional column variables will be ignored.


(default 20)


The lower limit for bins. The default is the minimum of the second variable.


The upper limit for bins. The default is the maximum of the second variable.


If true, the return will be a list where the original data.frame is returned as the second component with values of "BIN" added to the data.frame. This is useful from grouping when plotting with ggplot.


Given two corresponding variables in a data frame, defines bins in the second, bins the values of the first, and calculates the mean and standard deviation of the first in each bin. The purpose is to provide values for error bars, e.g., for geom_errorbar where ymin=ybar-sigma and ymax=ybar+sigma.


If addBIN == FALSE, dataframe of dimension c(bins, 4) that contains, for each bin, 'xc' = the center coordinate of the bin (2nd column), 'ybar' = the mean value for the bin (or NA if there are no members of the group), 'sigma' = the standard deviation for the bin, or NA for no members of the group, and 'nb' = the number of values in the bin. If addBin == TRUE, a replication of the input data.frame with a variable "BIN" added that denotes the classification of the first variable in bins of the second.


William Cooper


E <- binStats(RAFdata[, c("PSXC", "ATX")], bins=10)

NCAR/Ranadu documentation built on July 30, 2019, 11:08 p.m.