cut_directions | R Documentation |
Cuts direction vector into directional bins
cut_directions(directions, n_bins = 8, labels = NULL)
directions |
vector of directions to be binned, in degree, 0° being the North. |
n_bins |
number of bins, default: 8 sectors. |
labels |
optional character vector giving the sectors names. |
a factor vector the same size as directions
with the values binned into sectors.
# Example usage and demonstration
set.seed(123)
directions <- runif(20, 0, 360)
# Test with different numbers of bins
cat("Original directions:\n")
print(round(directions, 1))
cat("\n8 bins (default):\n")
bins_8 <- cut_directions(directions, n_bins = 8)
print(bins_8)
cat("\n4 bins:\n")
bins_4 <- cut_directions(directions, n_bins = 4)
print(bins_4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.