tab_each: Tabulate each variable separately

Description Usage Arguments Author(s) Examples

View source: R/tab_each.R

Description

Tabulate each variable separately

Usage

1
2
3
4
tab_each(data, cols = NULL, trunc.length = NULL,
  row.break.value = ".", complete = FALSE,
  arrange.factor.by = "value", show.percentage = TRUE,
  n.decimals = 0, include.na.percentage = TRUE)

Arguments

data

a data.frame

cols

a character specifying the variables to, if set to NULL all variables will be used

trunc.length

a numeric specificying the number of characters to use when truncating the output

row.break.value

the break value to use to separate variables in the output

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

Author(s)

Daniel Gardiner (daniel.gardiner@phe.gov.uk)

Examples

 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_each(data, cols = c("date", "sex", "conf", "geog"))

# using dplyr syntax

data %>%
select(date, sex, conf, geog) %>%
  tab_each()

DanielGardiner/EpiFunc documentation built on July 25, 2019, 10:53 p.m.