alex_na_plot: Prepares a Graph Displaying Missing Values in Panel Data

Description Usage Arguments Details Value Examples

View source: R/alex_na_plot.R

Description

Displays a heatmap of missing value frequency across the panel; Inspired by the ExPanDaR package approach as a basis

Usage

1
2
3
4
5
6
7
8
alex_na_plot(
  df,
  ts_id,
  no_factors = FALSE,
  binary = FALSE,
  colorx = 10,
  alphax = 1
)

Arguments

df

Data frame containing the data.

ts_id

A string containing the name of the variable indicating the time dimension. Needs to be coercible into an ordered factor.

no_factors

A logical value indicating whether you want to limit the plot to logical and numerical variables. Defaults to FALSE.

binary

If set to TRUE, the plot uses a binary scale only high-lightening whether values are missing or not. Defaults to FALSE.

colorx

- color scheme in terms of terrain.colors function from grDevices package (will be loaded and/or installed automatically inside this function) The basic value = 10 (10 means: red color for many missings; yellow color for moderate missing; green color for no or almost no missings)

alphax

- alpha of the color transparency function in terms of terrain.colors function from grDevices package; by default it is 1.

Details

alex_na_plot

This was inspired by a blog post of Rense Nieuwenhuis. And by ExPanDaR package :)

Thanks! You are the best!

This function has a useful add-on to adjust the design of the chart and select colors; by default it is intuitive reg-yellow-green scheme. Datasets with no missing values may be replicated yelow by default - nothing to compare with. You may change the color scheme and design any time.

Value

A ggplot2 plot. ggplot2, data.table and grDevices packages will be loaded, installed and loaded to your system automatically inside this function - whatever your system needs. If a package is installed - it will be called; if not - it will be installed and called automatically (user selection for the mirror to download the package may be needed).

Examples

1
2
library(plm); data("Produc", package="plm"); Produc$test = ifelse(Produc$unemp > 5, Produc$unemp, NA) #Adding NAs occasionally to the dataset
alex_na_plot(Produc, ts_id = "year")

Alexandershemetev/alexandershemetev documentation built on Dec. 30, 2020, 9:47 p.m.