plot_na: data visualization

Description Usage Arguments Details Value Examples

Description

plot_na uses dplyr and ggplot2 to return a stacked barplot showing the counts of NAs for each variable in the dataset.

Usage

1
2
3
plot_na(df, varcut = NULL, title = NULL, theme = "light",
  colors = c("darkgrey", "red"), base_font = "Fira Sans Condensed",
  title_font = "Fira Sans Condensed Medium")

Arguments

df

a data.frame object

varcut

a categorical variable to facet the plot.

title

a string defining the plot title

theme

a string defining theme: "light" (default) or "dark"

colors

a character vector of lenght 2, indicating NA and non-NA colors in the plot

base_font

a string indicating which font to use (default is Fira Sans Condensed)

title_font

a string indicating which font to use (default is Fira Sans Condensed Medium)

Details

This function is tidyverse based. It transforms the data in a tibble, gather and count NAs for each variable. Results are ploted in a stacked bar plot with geom_bar. Users can define title, colors, and can plot results grouped by one variable. In this case the plot will be faceted with facet_wrap horizontally displayed.

* mode options: "light" (default), or "dark"

Value

If varcut is not passed, then the function plot a simple stacked barplot showing the counts of NAs for each variable in the dataset. If is, then the counts are faceted.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# plot_na without varcut
plot_na(sample_data)

# plot_na with varcut (useful for time series data)
plot_na(sample_data, varcut = "year")

# plot_na manipulating other parameters
plot_na(
  sample_data,
  varcut = "year",
  title = "Counts of NAs",
  theme = "dark",
  colors = c("red", "darkgreen")
  )

bruno-pinheiro/seda documentation built on May 23, 2019, 1:59 a.m.