freqtable {questionr} | R Documentation |
Frequency table of variables
Description
Generate frequency tables for one or more variables in a data frame or a survey design.
Usage
freqtable(.data, ...)
## Default S3 method:
freqtable(.data, ..., na.rm = FALSE, weights = NULL)
## S3 method for class 'survey.design'
freqtable(.data, ..., na.rm = FALSE, weights = TRUE)
Arguments
.data |
a data frame or 'survey.design' object |
... |
one or more expressions accepted by |
na.rm |
Whether to remove missing values in the variables. |
weights |
If '.data' is a data frame, an optional expression selecting a weighting variable. If '.data' is a survey design, either 'TRUE' (the default) to to use survey weights, or 'FALSE' or 'NULL' to return unweighted frequencies. |
Value
The result is an array of class 'table'.
See Also
freq
, wtd.table
,
xtabs
, table
.
Examples
data(hdv2003)
freqtable(hdv2003, nivetud, sport)
freqtable(hdv2003, nivetud, sport, sexe)
freqtable(hdv2003, nivetud, sport, weights = poids)
freqtable(hdv2003, starts_with("trav"))
# Using survey design objects
library(survey)
hdv2003_wtd <- svydesign(ids = ~1, weights = ~poids, data = hdv2003)
freqtable(hdv2003_wtd, nivetud, sport)
# Compute percentages based on frequencies
hdv2003 |>
freqtable(sport) |>
freq()
hdv2003 |>
freqtable(sport, sexe) |>
prop()
hdv2003 |>
freqtable(sport, sexe) |>
cprop()
[Package questionr version 0.8.1 Index]