This function creates a categorical variable based on immigrant status (SDCFIMM), country of birth (SDCGCBG), ethnicity (SDCGCGT), and time in Canada (SDCGRES).
immigration_fun(SDCFIMM, SDCGCBG, SDCGCGT, SDCGRES)
SDCFIMM | Immigrant status (1-immigrant, 2-non-immigrant) |
---|---|
SDCGCBG | Country of birth (1-Canada, 2-Outside of Canada) |
SDCGCGT | Cultural or racial origin (1-white, 2-visible minority) |
SDCGRES | Length/time in Canada since immigration (1- 0-9 years, 2- 10+ years) |
Categorical variable (immigration_der) with six categories:
1 - White Canada-born
2 - Non-white Canadian born
3 - White immigrant born outside of Canada (0-9 years in Canada)
4 - Non-white immigrant born outside of Canada (0-9 years in Canada)
5 - White immigrant born outside of Canada (10+ years in Canada)
6 - Non-white immigrant born outside of Canada (10+ years in Canada)
immigration_der uses the CCHS variables that have been transformed by cchsflow. In order to generate a value for BMI across CCHS cycles, the following SDC variables must be transformed and harmonized.
# Using immigration_fun() to create immigration_der values across CCHS cycles # immigration_fun() is specified in variable_details.csv along with the # CCHS variables and cycles included. # To transform immigration_der, use rec_with_table() for each CCHS cycle # and specify immigration_der, along with the various SDC variables. # Then by using merge_rec_data() you can combine immigration_der across cycles. library(cchsflow) immigration2001 <- rec_with_table( cchs2001_p, c( "SDCFIMM", "SDCGCBG", "SDCGCGT", "SDCGRES", "immigration_der" ) )#>#>#>#>#>#>#> SDCFIMM SDCGCBG SDCGCGT SDCGRES immigration_der #> 1 2 1 1 NA(a) 1 #> 2 2 1 1 NA(a) 1 #> 3 1 2 1 1 3 #> 4 2 1 1 NA(a) 1 #> 5 2 1 1 NA(a) 1 #> 6 2 1 1 NA(a) 1immigration2009_2010 <- rec_with_table( cchs2009_2010_p, c( "SDCFIMM", "SDCGCBG", "SDCGCGT", "SDCGRES", "immigration_der" ) )#>#>#>#>#>#>#> SDCFIMM SDCGCBG SDCGCGT SDCGRES immigration_der #> 195 2 1 1 NA(a) 1 #> 196 2 1 1 NA(a) 1 #> 197 2 1 1 NA(a) 1 #> 198 2 1 2 NA(a) 2 #> 199 2 1 1 NA(a) 1 #> 200 1 2 1 2 5combined_immigration <- merge_rec_data(immigration2001, immigration2009_2010) head(combined_immigration)#> SDCFIMM SDCGCBG SDCGCGT SDCGRES immigration_der #> 1 2 1 1 NA(a) 1 #> 2 2 1 1 NA(a) 1 #> 3 1 2 1 1 3 #> 4 2 1 1 NA(a) 1 #> 5 2 1 1 NA(a) 1 #> 6 2 1 1 NA(a) 1#> SDCFIMM SDCGCBG SDCGCGT SDCGRES immigration_der #> 395 2 1 1 NA(a) 1 #> 396 2 1 1 NA(a) 1 #> 397 2 1 1 NA(a) 1 #> 398 2 1 2 NA(a) 2 #> 399 2 1 1 NA(a) 1 #> 400 1 2 1 2 5