Introducing pewmethods: An R package for working with survey data

Arnold Lau
Pew Research Center: Decoded
2 min readMar 26, 2020
(Pew Research Center illustration)

(Related posts: Exploring survey data with the pewmethods R package, Weighting survey data with the pewmethods R package and Analyzing international survey data with the pewmethods R package)

The Methods team at Pew Research Center is proud to release version 1.0 of pewmethods, an R package containing various functions that we use in our day-to-day survey data work. The package was originally envisioned as an internal way to reuse, maintain and share code. Since many of the problems that these functions were designed to solve are not unique to our projects, we are making the pewmethods package publicly available for other researchers who might also find it useful.

Survey data is a bit different from other kinds of data in that it frequently needs to be weighted to represent a larger population. The pewmethods package can help you through the steps for creating basic survey weights, as well as display weighted estimates of categorical variables. It is also an aid for the various cleaning, recoding, combining and collapsing tasks in between. In this way, our package complements the excellent survey package as well as the tidyverse set of R packages, which are great for data manipulation.

The pewmethods package is hosted on the Center’s Github page. You can get pewmethods by first installing the devtools package:

install.packages("devtools")

and then running the following line of code:

install_github("pewresearch/pewmethods", build_vignette = TRUE)

Vignettes require the rmarkdown and tidyverse packages. You can install the package without vignettes by setting build_vignettes to FALSE.

We’ve written a couple of introductions to the nuts and bolts of the package here and here. You can also find more information on the package’s home page.

Arnold Lau is a research analyst focusing on survey methodology at Pew Research Center.

--

--