univar_category.data.frame: Statistic of univariate categorical variables

View source: R/univariate.R

univar_categoryR Documentation

Statistic of univariate categorical variables

Description

The univar_category() calculates statistic of categorical variables that is frequency table

Usage

univar_category(.data, ...)

## S3 method for class 'data.frame'
univar_category(.data, ...)

Arguments

.data

a data.frame or a tbl_df.

...

one or more unquoted expressions separated by commas. You can treat variable names like they are positions. Positive values select variables; negative values to drop variables. These arguments are automatically quoted and evaluated in a context where column names represent column positions. They support unquoting and splicing.

Details

univar_category() calculates the frequency table of categorical variables. If a specific variable name is not specified, frequency tables for all categorical variables included in the data are calculated. The univar_category class returned by univar_category() is useful because it can draw chisqure tests and bar plots as well as frequency tables of individual variables. and return univar_category class that based list object.

Value

An object of the class as individual variables based list. The information to examine the relationship between categorical variables is as follows each components.

  • variable : factor. The level of the variable. 'variable' is the name of the variable.

  • n : integer. frequency by variable.

  • rate : double. relative frequency.

Attributes of return object

Attributes of compare_category class is as follows.

  • variables : character. List of variables selected for calculate frequency.

See Also

summary.univar_category, print.univar_category, plot.univar_category.

Examples


library(dplyr)

# Calculates the all categorical variables
all_var <- univar_category(heartfailure)

# Print univar_category class object
all_var

# Calculates the only smoking variable
all_var %>% 
  "["(names(all_var) %in% "smoking")

smoking <- univar_category(heartfailure, smoking)

# Print univar_category class object
smoking

# Filtering the case of smoking included NA 
smoking %>%
  "[["(1) %>% 
  filter(!is.na(smoking))

# Summary the all case : Return a invisible copy of an object.
stat <- summary(all_var)

# Summary by returned object
stat

# plot all variables
plot(all_var)

# plot smoking
plot(smoking)

# plot all variables by prompt
plot(all_var, prompt = TRUE)



dlookr documentation built on May 29, 2024, 2 a.m.