panelView – User Manual

Welcome

This manual serves as a user guide for the panelView package in R, which visualizes panel data. For the technical details, see Mou, Liu, and Xu (2022).

Installation

Source Version Date Features
CRAN 1.3.1 2026-05-13 Refreshed plot defaults; type = "network"; theme = "red"; group.mean.overlay
GitHub (master) 1.3.1 2026-05-13 Same as CRAN
GitHub (dev) 1.3.2 2026-05-14 + reversal-gap fix; dotted bridges for missing observations under leave.gap = FALSE
# From CRAN (stable release)
install.packages("panelView")
# Stable GitHub version (master branch)
devtools::install_github("xuyiqing/panelView")
# Development version (dev branch, includes type = "network")
devtools::install_github("xuyiqing/panelView@dev")
# Check installed version
installed.packages()["panelView", "Version"]
#> [1] "1.3.3"

panelView depends on the following packages, which should be installed automatically when panelView is being installed. You can also install them manually.

install_all <- function(packages) {
  installed_pkgs <- installed.packages()[, "Package"]
  for (pkg in packages) {
    if (!pkg %in% installed_pkgs) {
      install.packages(pkg)
    }
  }
}
packages <- c("ggplot2", "gridExtra", "grid", "dplyr")
install_all(packages)

The type = "network" plot additionally requires igraph, which is an optional (suggested) dependency:

Quick-reference

panelView has one main function, panelview(), with four core capabilities:

  1. Treatment status & missingness (type = "treat", type = "missing") — plot which units are treated in which periods, highlight missing values, and summarize treatment histories.

  2. Outcome trajectories (type = "outcome") — plot the raw outcome variable as time series, colored by treatment status.

  3. Bivariate relationships (type = "bivariate") — visualize the relationship between a treatment variable and an outcome variable, either in aggregate or unit by unit.

  4. Network structure (type = "network") — visualize the connectivity structure of panel data as a \(k\)-partite graph, identifying singletons, connected components, and duplicate observations. Supports two or more sets of fixed effects. See Correia (2016) for the graph-theoretic framework.

Argument Type Description
formula formula Y ~ D + X1 + X2; first RHS variable is the treatment
data data.frame Long-format panel data
index character c("unit_var", "time_var"); length \(\geq 2\) for type = "network"
type character "treat" / "missing" / "outcome" / "bivariate" / "network"
Y, D character Alternative to formula: variable names as strings
by.timing logical Sort units by timing of first treatment
pre.post logical Distinguish pre- and post-treatment periods (binary D only)
collapse.history logical Collapse units with identical treatment histories
show.id integer Plot only units ranked show.id (by alphabetical order)
id vector Plot only units whose ID matches id
by.group logical Split outcome plot by treatment-status group
by.cohort logical Collapse outcome by treatment-cohort (type=“outcome” only)
by.unit logical Plot Y and D per unit (type=“bivariate” only)
outcome.type character "continuous" (default) or "discrete"
leave.gap logical Show time gaps as white bars
axis.lab.angle numeric Angle of x-axis labels: 0, 45, or 90
legend.labs character Override legend labels
color character Override fill/line colors
legendOff logical Remove the legend
gridOff logical Remove grid lines (continuous treatment)
theme character "default" (blue) or "red" (high-contrast publication recipe)
group.mean.overlay logical Overlay group-mean line + 10–90% ribbon (type = "outcome")

Note that Y, D, and X are merely labels; they can be any variables in a panel dataset.

Shipped datasets

panelView ships three datasets for examples and testing:

Dataset Description Units Periods Balance
turnout US state voter turnout and election reform policies 47 states 24 elections (1920–2000) Balanced
capacity State institutional capacity across countries 47 countries 44 years (1960–2003) Balanced
simdata Simulated panel with staggered binary treatment 200 units 15 periods Balanced

All three are balanced panels. The network structure chapter uses inline simulation code to construct unbalanced panels that showcase singletons, connected components, and multi-way fixed effects.

Organization

Contributors

Report bugs

Please report bugs to yiqingxu [at] stanford.edu or open an issue on GitHub.

Lifecycle: stable License: MIT CRAN status downloads: CRAN