Skip to contents

Given a dataframe of survey responses, look for standard SurveyMonkey demographic questions and code/recode them into new variables that are more banner-, plot-, and analysis-friendly. Use code_std_demo_vars() to perform all standard demographic recodes, or select the specific function you need. Run std_demo_vars() to return the full index of SurveyMonkey's standard demographic variables.

Usage

code_geo_vars(data, append = TRUE, verbose = TRUE)

Arguments

data

Input data frame of survey responses.

append

If TRUE, append to existing dataframe otherwise return new variables in a fresh dataframe.

verbose

Print helpful messages.

Value

Survey data frame with new (or updated) columns corresponding to (if discoverable) respondents' geographic location (currently only in the U.S.):

  • zip: 6-digit ZIP code

  • urban4: 4-point urban/rural classification for ZIP code based on the USDA's 2010 RUCA (rural-urban commuting area) coding (Metropolitan, Micropolitan, Small town, Rural)

  • zip: 6-digit ZIP code

  • state_name: state name

  • state_abb: state abbreviation

  • region: U.S. Census region

  • division: U.S. Census division