centerBin | R Documentation |

This function cuts a vector of numeric data such that the breaks are set
using the middle value of a given bin rather than setting upper or lower
boundaries for each bin. For example, say you've got a vector of blood draw
times that weren't drawn at *exactly* the nominal time but were close to
it. Set the bins here to the nominal times, and the data will be filed into
the slot that's closest to the nominal time at which that sample should have
been drawn. For a similar option, see `cutNumeric`

or see the
base R function `cut`

.

```
centerBin(x, breaks)
```

`x` |
A numeric string |

`breaks` |
the desired breaks in that string set by what the middle value
should be. Any value of |

Returns a vector of numeric data

```
x <- c(48, 39, 28, 24, 5, 64, 133, 51, 59, 92, NA, 39)
centerBin(x, breaks = seq(0, 340, 5))
centerBin(x, breaks = seq(0, 340, 10))
# Let's look at an example where the times in a PK study weren't perfect.
ActualTime <- c(-5, 17, 32, 65, 118)
NominalTime <- c(0, 15, 30, 60, 120)
centerBin(ActualTime, breaks = NominalTime)
```

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.