Learn R Programming

ezsummary (version 0.1.9)

ezsummary_categorical: Easy summary for categorical data

Description

This function provided an easy-to-use way to display simple statistical summary for categorical data. It can be used together with select and group_by. If the piece of data passed into the function has one/multiple group_by variables, the percentage and count will be calculated within the defined groups.

Usage

ezsummary_categorical(tbl, n = FALSE, count = TRUE, p = TRUE, P = FALSE,
  round.N = 3, flavor = "long", unit_markup = NULL)

Arguments

Value

This function will organize all the results into one dataframe. If there are any group_by variables, the first few columns will be them. After these, the varible x will be the one listing all the categorical options in a format like "variable_option". The stats summaries are listed in the last few columns.

Examples

Run this code
library(dplyr)
mtcars %>% group_by(am) %>% select(cyl, gear, carb) %>% ezsummary_categorical()
mtcars %>% select(cyl, gear, carb) %>% ezsummary_categorical(n=TRUE, round.N = 2)

Run the code above in your browser using DataLab