View source: R/reindeeR_trackUtilities.R
bin_time | R Documentation |
This is a simple utility function to just create simple bins for a set of
time indicators (vector). The user supplies the number of bins needed, and this function
than returns a factor as long as the original vector, but with labels from
$1..bins$. That is, if the user sets bins=10, then the user gets a factor
where each value in the original vector has been given a number 1 to 10
according to what bin it belongs to. If the user wants percentage labels
instead, then the bins are renamed accordingly. For instance, if
bins=4,percent=FALSE
, then the user gets four bins named 1 to 4. If
bins=4,percent=TRUE
, then the user gets four bins labeled 25%, 50%,
75% and 100% respectively. The bins are always inclusive to the left, so that
the first bin will always include the lowest value. The 30% bin will include
values up until and including the value indicating the 30% cutoff of the
interval.
bin_time(x, bins = 10, percent = FALSE)
x |
The vector of values that need to be placed into discrete bins |
bins |
The number of bins. |
percent |
Should the bin labels instead indicate the (high) cutoff percentage? |
The function is just a convenience function and a wrapper around base::cut
(with include.lowest = TRUE,right = TRUE
), but is intended to ensure
uniform and reliable binning of track data by time so that data belonging to
the same segment may be combined even if extracted using different analysis
windows.
a factor with bins
bins, into which all items in x
have been places.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.