Learn R Programming

socviz

This is an R package of datasets and utility functions to accompany Data Visualization: A Practical Introduction (Princeton University Press, 2026).

What’s in this Package

The socviz package contains about thirty datasets and a number of utility and convenience functions used in Data Visualization: A Practical Introduction and of use to people producing data visualizations with R and ggplot.

Installation

To install the package, you can follow the instructions in the Preface to the book. Alternatively, and at a minimum, first download and install R for MacOS, Windows or Linux, as appropriate. Launch R, then type the following code at the Console prompt (>), hitting return at the end of each line:


install.packages("socviz")

To install the development version of socviz, instead of install.packages("socviz") do the following:


remotes::install_github("kjhealy/socviz")

Once everything has downloaded and been installed (which may take a little while), load the socviz package:

library(socviz)

More about the Datasets and Functions

The included datasets and functions are documented in the package and at https://kjhealy.github.io/socviz/reference/.

Copy Link

Version

Install

install.packages('socviz')

Monthly Downloads

905

Version

2.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Kieran Healy

Last Published

August 21st, 2026

Functions in socviz (2.0.0)

reexports

Objects exported from other packages
theme_socviz

A ggplot2 theme for socviz
studebt

Student debt data
int_to_year

int_to_year
titanic

A table of survival rates from the Titanic
states_sf

US State geometries
lawschools

US Law School Enrollments 1963-2015
counties_sf

US County geometries and demographic data
color_comp

Plot a table of color hex values as a table of colors
color_pal

Draw a palette of colors
center_df

center_df
%nin%

%nin%
prefix_replace

prefix_replace
prefix_strip

prefix_strip
tw_tab

Quickly make a two-way table of proportions (percentages)
round_df

round_df
theme_socviz_map

A map theme for socviz
elections_historic

US Presidential Election vote shares
color_table

A table of hex color values related to types of color blindness
acs_poverty

US County Poverty Rates by Age Group
election24

US Presidential Election 2024, State-level results
oecd_le

Life Expectancy in the OECD, 1960-2023.
gss_lon

General Social Survey data, 1972-2024
gss_sm

General Social Survey data, 2016
edu

Years of school completed by people 25 years and over in the US.
okboomer

Monthly Births in the U.S., 1933-2015
organdata

Organ donation in the OECD
county_data

Census Data on US Counties
county_map

US County map file
acs_poverty_lon

US County Poverty Rates by Age Group, Longer Version
yahoo

Yahoo Revenue and Employees
opiates

Opiate-Related Deaths in the United States, 1999-2020
election

US Presidential Election 2016, State-level results
maunaloa

Mauna Loa Atmospheric CO2 Concentration
election24_county_df

US County-level Presidential Election data, 2024
asasec

American Sociological Association Section Membership
farsinvolved

Child Pedestrians involved in Fatal Motor Vehicle Crashes, 2009-2023
fredts

Monetary Base and S&P 500 series
oecd_sum

Life Expectancy in the OECD, 1960-2023
county_comp

US County Components of Population Change