Description Usage Arguments Details Value Author(s) Examples

bin and calculate mean and st.dev. for each bin

1 2 |

`.d` |
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. |

`bins` |
(default 20) |

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

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

`addBin` |
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

1 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.