Learn R Programming

socviz

This is an R package of datasets, functions, and course materials to go along with the book Data Visualization: A Practical Introduction (Princeton University Press, 2019).

What's in this Package

The socviz package contains about twenty five datasets and a number of utility and convenience functions. Most of them are used in Data Visualization: A Practical Introduction (http://socviz.co), and there are also a few others as well for self-learners and students to practice their skills on.

A course packet is also included. This is a zipped file containing an R Studio project consisting of a nine R Markdown documents that parallel the chapters in the book. They contain the code for almost all the figures in the book (and a few more besides). Some support files are also included, to help demonstrate things like reading in your own data locally in R.

Installation

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



my_packages <- c("tidyverse", "fs", "devtools")
install.packages(my_packages)

install.packages("socviz")

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


devtools::install_github("kjhealy/socviz")

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

library(socviz)

The Course Packet

The supporting materials are contained in a compressed .zip file. To extract them to your Desktop, make sure the socviz package is loaded as described above. Then do something like this:


setup_course_notes(folder = "~/Desktop")

You can choose the destination folder, but you must supply one. Here, the dataviz_course_notes.zip file will be copied to your Desktop, and uncompressed there into a folder called dataviz_course_notes. Open the folder, and double-click the file named dataviz.Rproj to launch the project as a new RStudio session. If you want to uncompress the file somewhere other than your Desktop, e.g. your Documents folder, you can do this:


setup_course_notes(folder = "~/Documents")

More about the Datasets and Functions

The included datasets and functions are documented at http://kjhealy.github.io/socviz/reference/.

Copy Link

Version

Install

install.packages('socviz')

Monthly Downloads

1,126

Version

1.2

License

MIT + file LICENSE

Maintainer

Kieran Healy

Last Published

June 10th, 2020

Functions in socviz (1.2)

center_df

center_df
asasec

American Sociological Association Section Membership
color_comp

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

Draw a palette of colors
bad_date

Dates in character form
color_table

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

US County map file
boomer

Monthly Births in the US, and England & Wales
edu

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

Census Data on US Counties
oecd_le

Life Expectancy in the OECD, 1960-2015.
elections_historic

US Presidential Election vote shares
lay_out

Arrange ggplot2 plots in an arbitrary grid
fredts

Monetary Base and S&P 500 series
election

US Presidential Election 2016, State-level results
freq_tab

Generate a tidy n-way frequency table
%nin%

%nin%
gss_lon

General Social Survey data, 1972-2016
oecd_sum

Life Expectancy in the OECD, 1960-2015
int_to_year

int_to_year
prefix_replace

prefix_replace
gss_sib

General Social Survey data, 1972-2016
gss_sm

General Social Survey data, 2016
lawschools

US Law School Enrollments 1963-2015
maunaloa

Mauna Loa Atmospheric CO2 Concentration
opiates

Opiate-Related Deaths in the United States, 1999-2014
prefix_strip

prefix_strip
reexports

Objects exported from other packages
preg

An untidy table of data
preg2

A wider table of untidy data
round_df

round_df
titanic

A table of survival rates from the Titanic
studebt

Student debt data
setup_course_notes

setup_course_notes
tw_tab

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

Organ donation in the OECD
yahoo

Yahoo Revenue and Employees