compmeans {descr} | R Documentation |
Calculates the means of a numerical vector according to a factor.
compmeans(x, f, w, sort = FALSE, maxlevels = 60, user.missing, plot = getOption("descr.plot"), relative.widths = TRUE, col = "lightgray", ...)
x |
A numeric vector. |
f |
A factor. |
w |
Optional vector with weights. |
sort |
If |
maxlevels |
Maximum number of levels that |
user.missing |
Character vector, indicating what levels of |
plot |
Logical: if
in your ‘.Rprofile’ to change the default function behavior. |
relative.widths |
If |
col |
Vector with the boxes colors. |
... |
Further arguments to be passed to either
|
A matrix with class c("matrix", "meanscomp")
with labels attributes
for x
and f
. The returned object can be plotted, generating
a boxplot
of x
grouped by f
.
Jakson A. Aquino, jalvesaq@gmail.com.
educ <- sample(c(1, 2), 200, replace = TRUE, prob = c(0.3, 0.7)) educ <- factor(educ, levels = c(1, 2), labels = c("Low", "High")) income <- rnorm(200, 1000, 100) + 100 * as.numeric(educ) attr(educ, "label") <- "Education level" attr(income, "label") <- "Income" w <- sample(c(10, 15, 19), 200, replace = TRUE) compmeans(income, educ, col = c("#FFD0E0", "#D8E8FF")) comp <- compmeans(income, educ, w, plot = FALSE) comp plot(comp) ## Not run: print(xtable(comp)) # If the decimal separator in your country is a comma: # options(OutDec = ",") print(xtable(comp, align = "lrrr", display = c("s", "f", "d", "f"))) ## End(Not run)