Learn R Programming

glancedata (version 1.0.1)

plot_discrete_vars: Plot Discrete Variables

Description

Creates a grid of bar plots for variables with at most nvalues (15 is the default) different values.

Usage

plot_discrete_vars(x, nvalues = 15, sort_by_frequency = FALSE)

Arguments

x

Data frame, tibble or matrix with data.

nvalues

Integer. It creates a bar plot for each variable with at most this amount of different values. The default value is 15.

sort_by_frequency

Logical. It casts every variable to factor and then reorders the levels by frequency before generating the plot.

Value

A GGplot object.

Examples

Run this code
# NOT RUN {
library(glancedata)

plot_discrete_vars(mtcars)
plot_discrete_vars(mtcars, sort_by_frequency = TRUE)
plot_discrete_vars(iris)

## The following two examples give a warning because they don't
## have any variable with fewer than 15 different values.
plot_discrete_vars(cars)
plot_discrete_vars(state.x77)
# }

Run the code above in your browser using DataLab