to_cd: Concatenate to Congressional District code

View source: R/district-coding.R

to_cdR Documentation

Concatenate to Congressional District code

Description

Concatenate to Congressional District code

Usage

to_cd(state, num)

Arguments

state

A vector of state names, preferably abbreviations. If it is numeric, the function will assume they are FIPS codes and translate them accordingly. If they have full names like "California" instead of "CA", it will trnslate that too.

num

A vector of district codes

Examples

library(dplyr)

 to_cd(c("AL", "AK"), c("5", "AL"))
 to_cd(c(1, 2), c("5", "AL"))
 to_cd(c("Alabama", "Alaska"), c("5", "AL"))

 transmute(cc18_samp,
           inputstate,
           cdid115,
           cd = to_cd(inputstate, cdid115))


kuriwaki/ccesMRPprep documentation built on July 27, 2023, 3:34 a.m.