tabs {questionr} | R Documentation |
Weighted Crossresult
Description
Generate table with multiple weighted crossresult (full sample is first column). kable(), which is found in library(knitr), is recommended for use with RMarkdown.
Usage
tabs(
df,
x,
y,
type = "percent",
percent = FALSE,
weight = NULL,
normwt = FALSE,
na.rm = TRUE,
na.show = FALSE,
exclude = NULL,
digits = 1
)
Arguments
df |
A data.frame that contains |
x |
variable name (found in |
y |
one (or more) variable names. tabs(my.data, x = 'q1', y = c('sex', 'job')). |
type |
'percent' (default ranges 0-100), 'proportion', or 'counts' (type of table returned). |
percent |
if |
weight |
variable name for weight (found in |
normwt |
if TRUE, normalize weights so that the total weighted count is the same as the unweighted one |
na.rm |
if TRUE, remove NA values before computation |
na.show |
if TRUE, show NA count in table output |
exclude |
values to remove from x and y. To exclude NA, use na.rm argument. |
digits |
Number of digits to display; ?format.proptab for formatting details. |
Details
tabs calls wtd.table on 'x
' and, as applicable, each variable named by 'y
'.
Author(s)
Pete Mohanty
Examples
data(hdv2003)
tabs(hdv2003, x = "relig", y = c("qualif", "trav.imp"), weight = "poids")
result <- tabs(hdv2003, x = "relig", y = c("qualif", "trav.imp"), type = "counts")
format(result, digits = 3)
# library(knitr)
# xt <- tabs(hdv2003, x = "relig", y = c("qualif", "trav.imp"), weight = "poids")
# kable(format(xt)) # to use with RMarkdown...