# Bin data, calculate mean and bootstrap 95% confidence interval in the mean

Source:`R/utilities.R`

`binData.Rd`

Bin a variable and calculate mean an uncertainties in mean

## Arguments

- mydata
Name of the data frame to process.

- bin
The name of the column to divide into intervals

- uncer
The name of the column for which the mean, lower and upper uncertainties should be calculated for each interval of

`bin`

.- n
The number of intervals to split

`bin`

into.- interval
The interval to be used for binning the data.

- breaks
User specified breaks to use for binning.

## Value

Retruns a summarised data frame with new columns for the mean and upper / lower 95% confidence intervals in the mean.

## Details

This function summarises data by intervals and calculates the mean and bootstrap 95% confidence intervals in the mean of a chosen variable in a data frame. Any other numeric variables are summarised by their mean intervals.

There are three options for binning. The default is to bon `bin`

into 40
intervals. Second, the user can choose an binning interval e.g.
`interval = 5`

. Third, the user can supply their own breaks to use as
binning intervals.

## Examples

```
# how does nox vary by intervals of wind speed?
results <- binData(mydata, bin = "ws", uncer = "nox")
# easy to plot this using ggplot2
if (FALSE) {
library(ggplot2)
ggplot(results, aes(ws, mean, ymin = min, ymax = max)) +
geom_pointrange()
}
```