| cutf2 | R Documentation | 
This is a copy of Frank Harell's Hmisc::cut2 function which uses the
additional parameters format_fun and ... to apply custom formatting to
the input. By default it behaves exactly like Hmisc::cut2
cutf2(
  x,
  cuts,
  m = 150,
  g,
  levels.mean = FALSE,
  digits,
  minmax = TRUE,
  oneval = TRUE,
  onlycuts = FALSE,
  format_fun = format,
  ...
)
| x | numeric vector to classify into intervals | 
| cuts | cut points | 
| m | desired minimum number of observations in a group. The algorithm does not guarantee that all groups will have at least m observations. | 
| g | number of quantile groups | 
| levels.mean | set to TRUE to make the new categorical vector have levels attribute that is the group means of x instead of interval endpoint labels | 
| digits | number of significant digits to use in constructing levels.
Default is 3 (5 if  | 
| minmax | if cuts is specified but  | 
| oneval | if an interval contains only one unique value, the interval
will be labeled with the formatted version of that value instead of the
interval endpoints,  | 
| onlycuts | set to  | 
| format_fun | formatting function | 
| ... | additional arguments passed to  | 
a factor variable with levels of the form [a,b) or formatted means
(character strings) unless onlycuts is TRUE in which case a numeric
vector is returned
set.seed(1)
Z <- 1000*stats::rnorm(10000)
table(cutf2(Z, c(-10005, -5000, 100, 0, 50, 10000)))
table(cutf2(Z, c(-10005, -5000, 100, 0, 50, 10000), format_fun = formatC))
table(cutf2(Z, c(-10005, -5000, 100, 0, 50, 10000), format_fun = format_metric))
table(cutf2(Z, g=10))      # quantile groups
table(cutf2(Z, g=10, format_fun = formatC))
table(cutf2(Z, g=10, format_fun = format_metric))
table(cutf2(Z, m=500))      # group x into intevals with at least 50 obs.
table(cutf2(Z, m=500, format_fun = formatC))
table(cutf2(Z, m=500, format_fun = format_metric))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.