Learn R Programming

tidystats (version 0.3)

count_data: Count the total of observations

Description

count_data returns the number of observations for categorical variables.

Usage

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

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab