Description Usage Arguments Author(s) Examples
Tabulate 1 variable
1 2 3 |
data |
a data.frame |
var |
a character specifying the variable to tabulate, if set to NULL the first variable will be used |
complete |
a logical specifying whether to use all levels for factor variables |
arrange.factor.by |
a character with value either "level" or "value" describing how a factor variable should be ordered |
show.percentage |
a logical specifying whether to show percentages in output |
Daniel Gardiner (daniel.gardiner@phe.gov.uk)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # set dummy data
set.seed(4)
data = data.frame(date = sample(seq(as.Date("2017-01-01"), as.Date("2018-06-01"), 1), 200, replace = TRUE),
sex = factor(c("M", "M", "F", NA, NA), c("F", "M", "Unk")),
conf = sample(c("Confirmed", "Probable", "Probable"), 200, replace = TRUE),
status = sample(c("Student", "Staff", NA), 200, replace = TRUE),
geog = sample(c("South", "North"), 200, replace = TRUE))
# apply function
tab_1var(data, "sex")
# using dplyr syntax
data %>%
select(sex) %>%
tab_1var()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.