{"id":111525,"date":"2020-03-26T17:12:00","date_gmt":"2020-03-26T22:12:00","guid":{"rendered":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/\/\/introducing-pewmethods-an-r-package-for-working-with-survey-data\/"},"modified":"2024-04-17T05:13:42","modified_gmt":"2024-04-17T09:13:42","slug":"introducing-pewmethods-an-r-package-for-working-with-survey-data","status":"publish","type":"decoded","link":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2020\/03\/26\/introducing-pewmethods-an-r-package-for-working-with-survey-data\/","title":{"rendered":"Introducing pewmethods: An R package for working with survey data"},"content":{"rendered":"\n<figure class=\"wp-block-image size-640-wide\"><a rel=\"attachment wp-att-139490\" href=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2020\/03\/introducing-pewmethods-an-r-package-for-working-with-survey-data\/2020-03-26_decoded_featured-png\/\"><img data-dominant-color=\"647e93\" data-has-transparency=\"false\" style=\"--dominant-color: #647e93;\" loading=\"lazy\" decoding=\"async\"  srcset=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?resize=480,270 480w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?resize=782,440 782w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?resize=960,540 960w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?resize=1200,675 1200w, https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?resize=1400,787 1400w\" sizes=\"(max-width: 480px) 480px, (max-width: 782px) 782px, 640px\" height=\"360\" width=\"640\" src=\"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=640\" alt=\"\" class=\"wp-image-139490 not-transparent\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"b667\"><em>(Related posts:&nbsp;<\/em><a href=\"https:\/\/medium.com\/pew-research-center-decoded\/exploring-survey-data-with-the-pewmethods-r-package-198c4eb9d1af\"><em>Exploring survey data with the pewmethods R package<\/em><\/a><em>,&nbsp;<\/em><a href=\"https:\/\/medium.com\/pew-research-center-decoded\/weighting-survey-data-with-the-pewmethods-r-package-d040afb0d2c2\"><em>Weighting survey data with the pewmethods R package<\/em><\/a><em>&nbsp;and&nbsp;<\/em><a href=\"https:\/\/medium.com\/pew-research-center-decoded\/analyzing-international-survey-data-with-the-pewmethods-r-package-3b0b21cba607\"><em>Analyzing international survey data with the pewmethods R package<\/em><\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"f712\">The Methods team at Pew Research Center is proud to release&nbsp;<a href=\"https:\/\/github.com\/pewresearch\/pewmethods\" rel=\"noreferrer noopener\" target=\"_blank\">version 1.0 of pewmethods<\/a>, 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"4b01\">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&nbsp;<a href=\"https:\/\/medium.com\/pew-research-center-decoded\/using-tidyverse-tools-with-pew-research-center-survey-data-in-r-bdfe61de0909\">great for data manipulation<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"0ec2\">The pewmethods package is hosted on&nbsp;<a href=\"https:\/\/github.com\/pewresearch\/\" target=\"_blank\" rel=\"noreferrer noopener\">the Center\u2019s Github page<\/a>. You can get pewmethods by first installing the devtools package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install.packages(\"devtools\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and then running the following line of code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>install_github(\"pewresearch\/pewmethods\", build_vignette = TRUE)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"82d5\">Vignettes require the&nbsp;<strong>rmarkdown<\/strong>&nbsp;and&nbsp;<strong>tidyverse<\/strong>&nbsp;packages. You can install the package without vignettes by setting build_vignettes to FALSE.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"fe0b\">We\u2019ve written a couple of introductions to the nuts and bolts of the package&nbsp;<a href=\"https:\/\/medium.com\/pew-research-center-decoded\/exploring-survey-data-with-the-pewmethods-r-package-198c4eb9d1af\">here<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/medium.com\/pew-research-center-decoded\/weighting-survey-data-with-the-pewmethods-r-package-d040afb0d2c2\">here<\/a>. You can also find more information on the package\u2019s&nbsp;<a href=\"https:\/\/github.com\/pewresearch\/pewmethods\" rel=\"noreferrer noopener\" target=\"_blank\">home page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our new R package contains various functions that we use in our day-to-day survey work.<\/p>\n","protected":false},"author":377,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"sub_headline":"","sub_title":"","_prc_public_revisions":[],"_ppp_expiration_hours":0,"_ppp_enabled":false,"ai_generated_summary":"","relatedPosts":[],"_prc_fork_parent":0,"_prc_fork_status":"","_prc_active_fork":0,"datacite_doi":"","datacite_doi_citation":"","_prc_seo_qr_attachment_id":0,"spoken_article_player_enabled":true,"displayBylines":true,"footnotes":"","prc_watchers":[]},"categories":[357],"bylines":[719],"collection":[],"_post_visibility":[],"decoded-category":[531,532],"formats":[],"_fund_pool":[],"languages":[],"regions-countries":[],"research-teams":[524],"workflow-status":[],"class_list":["post-111525","decoded","type-decoded","status-publish","hentry","category-survey-methods","bylines-arnold-lau","decoded-category-coding-how-to","decoded-category-survey-methods","research-teams-decoded"],"label":"Decoded","post_parent":0,"word_count":299,"canonical_url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/decoded\/2020\/03\/26\/introducing-pewmethods-an-r-package-for-working-with-survey-data\/","art_direction":{"A1":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=564&h=317&crop=1","width":564,"height":317,"caption":"","chartArt":false},"A2":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=268&h=151&crop=1","width":268,"height":151,"caption":"","chartArt":false},"A3":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=194&h=110&crop=1","width":194,"height":110,"caption":"","chartArt":false},"A4":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=268&h=151&crop=1","width":268,"height":151,"caption":"","chartArt":false},"XL":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=720&h=405&crop=1","width":720,"height":405,"caption":"","chartArt":false},"social":{"id":139490,"rawUrl":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png","url":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-content\/uploads\/sites\/20\/2022\/08\/2020.03.26_decoded_featured.png?w=1200&h=628&crop=1","width":1200,"height":628,"caption":"","chartArt":false}},"_embeds":[],"watchers":[],"table_of_contents":[],"datacite_doi":"","prc_seo_data":{"title":"Introducing pewmethods: An R package for working with survey data","description":"Our new R package contains various functions that we use in our day-to-day survey work.","og_title":"Introducing pewmethods: An R package for working with survey data","og_description":"Our new R package contains various functions that we use in our day-to-day survey work.","schema_type":"Article","noindex":false,"canonical_url":"","primary_terms":{"category":42},"custom_schema":[],"og_image":139490,"indexnow_submitted_at":null,"gsc_index_status":null},"prepublish_checks":{},"jetpack_sharing_enabled":true,"relatedPostsOrdered":[],"bylinesOrdered":[{"key":"_mzzgn40wp","termId":719}],"acknowledgementsOrdered":[],"_links":{"self":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded"}],"about":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/types\/decoded"}],"author":[{"embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/users\/377"}],"replies":[{"embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/comments?post=111525"}],"version-history":[{"count":2,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111525\/revisions"}],"predecessor-version":[{"id":139518,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded\/111525\/revisions\/139518"}],"wp:attachment":[{"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/media?parent=111525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/categories?post=111525"},{"taxonomy":"bylines","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/bylines?post=111525"},{"taxonomy":"collection","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/collection?post=111525"},{"taxonomy":"_post_visibility","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/_post_visibility?post=111525"},{"taxonomy":"decoded-category","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/decoded-category?post=111525"},{"taxonomy":"formats","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/formats?post=111525"},{"taxonomy":"_fund_pool","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/_fund_pool?post=111525"},{"taxonomy":"languages","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/languages?post=111525"},{"taxonomy":"regions-countries","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/regions-countries?post=111525"},{"taxonomy":"research-teams","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/research-teams?post=111525"},{"taxonomy":"workflow-status","embeddable":true,"href":"https:\/\/alpha.pewresearch.org\/pewresearch-org\/wp-json\/wp\/v2\/workflow-status?post=111525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}