| margin_categorical | R Documentation |
margin_categorical() builds a quantile function for a categorical
variable; margin_empirical() builds the (interpolated) empirical
quantile function of observed data, preserving its class.
margin_categorical(levels, probs = NULL, ordered = FALSE)
margin_empirical(x, interpolation = c("linear", "spline"))
levels |
Category labels. |
probs |
Category probabilities (normalised internally). |
ordered |
Return an ordered factor? |
x |
Observed data (numeric, integer, Date, POSIXct, factor, character, logical). |
interpolation |
|
A function of p returning values.
q <- margin_categorical(c("low", "mid", "high"), c(0.2, 0.5, 0.3), ordered = TRUE)
table(q(runif(1000)))
qe <- margin_empirical(faithful$eruptions)
summary(qe(runif(1000)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.