cut_ws | R Documentation |
Based on base::cut()
. Allows to specifiy maximum wind velocity. If squish = TRUE
the values greater than ws_max
will be combined to one additional factor level ">ws_max". If squish = FALSE
the resulting vector will contain
NA for this values. The correct handling of the NA values in the factor must be done by the user.
cut_ws(
ws,
binwidth = 1,
ws_max = NA,
squish = TRUE,
right = TRUE,
reverse = FALSE,
calm = NA
)
ws |
numeric vector of wind velocity |
binwidth |
width of the bins |
ws_max |
cut off wind speed at this maximum |
squish |
If TRUE wind velocities greater than will be include as additional level ">ws_max" |
right |
logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa. |
reverse |
reverse order of result. This is sometimes useful when plotting a factor. |
calm |
threshold for calm wind situation. All windspeed below this limit will be assigned the the factor level "calm". |
ws <- c(0.3, 1.1, 2.2, 3.3, 4.4, 5, 8.8)
cut_ws(ws, binwidth = 2)
# if ws_max not a multiple of binwidth, the last level before squishing will be cut short
cut_ws(ws, binwidth = 2, ws_max = 5)
# calm support: all wind speed below threshold will be gathered in the class calm
cut_ws(ws, ws_max = 5, calm = 0.5)
cut_ws(ws, binwidth = 2, ws_max = 5, squish = FALSE)
# close the intervals on the left side
# unfortunately there is a issue in converting the console output to
# html: the unicode character for >= gets scrambled to =
# https://github.com/r-lib/evaluate/issues/59
cut_ws(ws, binwidth = 2, ws_max = 5, right = FALSE)
# reverse the order of the factors, useful for legends while plotting
cut_ws(ws, binwidth = 2, ws_max = 5, reverse = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.