Description Usage Arguments Value Examples
The first step in binning/down-sampling some data is assigning items to bins. This function takes a vector and a bin size and returns the bin assignments.
1 | AssignBins(xs, bin_width = 3, na_location = "tail", partial = FALSE)
|
xs |
a vector |
bin_width |
the number of items to put in each bin. Default is 3. |
na_location |
Where to assign |
partial |
whether to exclude values that don't fit evenly into bins. Defaults to FALSE, so that the user is warned if a bin is incomplete. |
a vector of bin-numbers. If bin_width
does not evenly divide
xs
, the remainder elements are given a bin number of NA
.
1 2 3 4 5 6 7 8 | AssignBins(1:14, bin_width = 3, "head")
# [1] NA NA 1 1 1 2 2 2 3 3 3 4 4 4
AssignBins(1:14, bin_width = 3, "tail")
# [1] 1 1 1 2 2 2 3 3 3 4 4 4 NA NA
AssignBins(1:7, bin_width = 5, "split")
# [1] NA 1 1 1 1 1 NA
AssignBins(1:8, bin_width = 5, "split")
# [1] NA 1 1 1 1 1 NA NA
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.