| cutter | R Documentation |
Thin wrappers around ggplot2::cut_interval() and friends.
Useful for defining fixed x values for fitting functions.
cutter_interval(df, n, ...) cutter_number(df, n, ...) cutter_width(df, width, ...) cutter_to_seq(x)
df |
a |
n |
number of intervals to create or the approximate number of observations |
... |
colnames |
width |
width of intervals to create |
x |
a cutter on which to extract breaks |
Here, columns of interest may be passed directly.
If you want to cut directly on numeric vectors,
use base::cut() or ggplot2::cut_interval() and friends.
factor with appropriate levels
cutter_interval: makes groups with equal range
cutter_number: makes n groups with approximately equal numbers of observations
cutter_width: makes groups of a certain width
cutter_to_seq: extract breaks from a cutter factor
cutter_interval(animals, 30, tpq, taq) %>% table()
cutter_number(animals, 10, tpq, taq,) %>% table()
cutter_width(animals, 30, tpq, taq) %>% table()
# # note that in x_cut_number above, we have many observations yet
# the number of _different_ levels is not so diverse,
# so that n=30 would fail with "Insufficient data values"
# unlist(animals[, c("tpq", "taq")]) %>% table()
# cutter_to_seq is helpful to pass x_bin/x_pred to bin/fit_* respectively
# there is an example in ?bin that can be used to fit_* too
# cutter_to_seq go back to numeric from factor levels:
cutter_width(animals, 30, tpq, taq) %>% cutter_to_seq()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.