plot_counts {volker} | R Documentation |
Output a frequency plot
Description
The type of frequency plot depends on the number of selected columns:
One column: see plot_counts_one
Multiple columns: see plot_counts_items
One column and one grouping column: see plot_counts_one_grouped
Multiple columns and one grouping column: see plot_counts_items_grouped (not yet implemented)
By default, if you provide two column selections, the second column is treated as categorical. Setting the metric-parameter to TRUE will call the appropriate functions for correlation analysis:
One column and one metric column: see plot_counts_one_cor (not yet implemented)
Multiple columns and one metric column: see plot_counts_items_cor (not yet implemented)
Usage
plot_counts(data, cols, cross = NULL, metric = FALSE, clean = TRUE, ...)
Arguments
data |
A data frame. |
cols |
A tidy column selection, e.g. a single column (without quotes) or multiple columns selected by methods such as starts_with(). |
cross |
Optional, a grouping column. The column name without quotes. |
metric |
When crossing variables, the cross column parameter can contain categorical or metric values. By default, the cross column selection is treated as categorical data. Set metric to TRUE, to treat it as metric and calculate correlations. |
clean |
Prepare data by data_clean. |
... |
Other parameters passed to the appropriate plot function. |
Value
A ggplot2 plot object.
Examples
library(volker)
data <- volker::chatgpt
plot_counts(data, sd_gender)