Frequencies of labelled variables

Share:

Description

This function returns a frequency table of labelled vectors, as data frame.

Usage

1
frq(x, sort.frq = c("none", "asc", "desc"))

Arguments

x

A labelled vector or a data.frame with labelled vectors.

sort.frq

Logical, if TRUE, rows will be sorted according to value frequencies.

Value

A data frame with values, value labels, frequencies, raw, valid and cumulative percentages of x.

See Also

flat_table for labelled (proportional) tables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(haven)
# create labelled integer
x <- labelled(c(1, 2, 1, 3, 4, 1),
              c(Male = 1, Female = 2, Refused = 3, "N/A" = 4))
frq(x)

x <- labelled(c(1:3, tagged_na("a", "c", "z"), 4:1, 2:3),
              c("Agreement" = 1, "Disagreement" = 4, "First" = tagged_na("c"),
                "Refused" = tagged_na("a"), "Not home" = tagged_na("z")))
frq(x)

# in a pipe
data(efc)
library(dplyr)
efc %>% select(e42dep, e15relat, c172code) %>% frq()

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.