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 translate that too. But you cannot mix different types.

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 Oct. 26, 2024, 10:22 p.m.