count_data: Count the total of observations

Description Usage Arguments Details Examples

View source: R/count_data.r

Description

count_data returns the number of observations for categorical variables.

Usage

1
count_data(data, ..., na.rm = TRUE)

Arguments

data

A data frame.

...

One or more unquoted (categorical) column names from the data frame, separated by commas.

na.rm

Logical. Should missing values (including NaN) be removed?

Details

The data frame can be grouped using dplyr's group_by so that the total of observations will be calculated for each group level.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dplyr)

# 1 variable
count_data(cox, sex)

# 2 variables
count_data(cox, condition, sex)

# 1 variable, 1 group
cox %>%
  group_by(condition) %>%
  count_data(sex)

WillemSleegers/tidystats-v0.3 documentation built on Aug. 12, 2019, 5:31 p.m.