diff --git a/.DS_Store b/.DS_Store index 9bab5e58..dea71d61 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/DESCRIPTION b/DESCRIPTION index 149d4631..552c90c4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cchsflow Type: Package Title: Transforming and harmonizing CCHS variables -Version: 0.2.2 +Version: 0.2.3 Authors@R: c( person(given = "Doug", family = "Manuel", diff --git a/NAMESPACE b/NAMESPACE index a27b30b4..2d5c6956 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(ALCDTYP) export(ALWDDLY) export(ALWDWKY) export(BMI_fun) +export(DHHGAGE_cat_fun) export(Pack_years_fun) export(Pct_time_fun) export(Resp_condition_fun1) diff --git a/NEWS.md b/NEWS.md index 9eeb3376..0f1e4b96 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ ## Features - Updated example in the introduction (README.MD) to reflect data that is now included in the cchsflow package. +- Updates to vignettes to reflect latest version of package ### Variables diff --git a/_pkgdown.yml b/_pkgdown.yml index 90553303..d029f877 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -55,6 +55,7 @@ reference: - Resp_condition_fun1 - Resp_condition_fun2 - Resp_condition_fun3 + - DHHGAGE_cat_fun - title: "CCHS datasets" desc: Datasets for each CCHS cycle contents: diff --git a/docs/.DS_Store b/docs/.DS_Store index fcefad82..b9ffaac2 100644 Binary files a/docs/.DS_Store and b/docs/.DS_Store differ diff --git a/docs/404.html b/docs/404.html index afee4143..7df74d78 100644 --- a/docs/404.html +++ b/docs/404.html @@ -73,7 +73,7 @@
diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 93cea9e3..aa343c32 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -73,7 +73,7 @@ diff --git a/docs/articles/derivedVariables.html b/docs/articles/derivedVariables.html index 1b7ace95..a2c50abf 100644 --- a/docs/articles/derivedVariables.html +++ b/docs/articles/derivedVariables.html @@ -38,7 +38,7 @@ @@ -156,64 +156,47 @@data(cchs2003)
data(cchs2010)
-variables <- read.csv(file.path(getwd(), '../inst/extdata/variables.csv'))
-variableDetails <- read.csv(file.path(getwd(), '../inst/extdata/variableDetails.csv'))
-
BMI2003 <- RecWTable(dataSource = cchs2003, variableDetails = variableDetails, datasetName = "cchs2003", log = TRUE, variables = c("HWTGHTM", "HWTGWTK", "HWTGBMI_der"))
## [1] "NOTE: 2001 and 2003 CCHS use inches, values converted to meters to 3 decimal points"
## [1] "NOTE: 74+ inches converted to 76 inches"
## [1] "The variable HWTCGHT was recoded into HWTGHTM for the database cchs2003 the following recodes were made:"
-## valueTo From rowsRecoded
-## 1 1.118 1 0
-## 2 1.143 2 0
-## 3 1.168 3 0
-## 4 1.194 4 0
-## 5 1.219 5 0
-## 6 1.245 6 0
-## 7 1.270 7 0
-## 8 1.295 8 0
-## 9 1.321 9 0
-## 10 1.346 10 0
-## 11 1.372 11 0
-## 12 1.397 12 0
-## 13 1.422 13 0
-## 14 1.448 14 1
-## 15 1.473 15 0
-## 16 1.499 16 2
-## 17 1.524 17 5
-## 18 1.549 18 8
-## 19 1.575 19 14
-## 20 1.600 20 16
-## 21 1.626 21 17
-## 22 1.651 22 19
-## 23 1.676 23 17
-## 24 1.702 24 25
-## 25 1.727 25 16
-## 26 1.753 26 10
-## 27 1.778 27 13
-## 28 1.803 28 14
-## 29 1.829 29 10
-## 30 1.854 30 6
-## 31 1.930 31 6
-## 32 NA::a 96 0
-## 33 NA::b 99 1
+## # A tibble: 33 x 3
+## valueTo From rowsRecoded
+## <chr> <chr> <int>
+## 1 1.118 1 0
+## 2 1.143 2 0
+## 3 1.168 3 0
+## 4 1.194 4 0
+## 5 1.219 5 0
+## 6 1.245 6 0
+## 7 1.270 7 0
+## 8 1.295 8 0
+## 9 1.321 9 0
+## 10 1.346 10 0
+## # … with 23 more rows
## [1] "The variable HWTCGWTK was recoded into HWTGWTK for the database cchs2003 the following recodes were made:"
-## valueTo From rowsRecoded
-## 1 copy 27.0:135.0 192
-## 2 NA::a 996 0
-## 3 NA::b 997:999 0
+## # A tibble: 3 x 3
+## valueTo From rowsRecoded
+## <chr> <chr> <int>
+## 1 copy 27.0:135.0 192
+## 2 NA::a 996 0
+## 3 NA::b 997:999 0
BMI2010 <- RecWTable(dataSource = cchs2010, variableDetails = variableDetails, datasetName = "cchs2010", log = TRUE, variables = c("HWTGHTM", "HWTGWTK", "HWTGBMI_der"))
## [1] "NOTE: Height is a reported in meters from 2005 CCHS onwards"
## [1] "The variable HWTGHTM was recoded into HWTGHTM for the database cchs2010 the following recodes were made:"
-## valueTo From rowsRecoded
-## 1 copy 0.914:2.134 190
-## 2 NA::a 9.996 2
-## 3 NA::b 9.997:9.999 0
+## # A tibble: 3 x 3
+## valueTo From rowsRecoded
+## <chr> <chr> <int>
+## 1 copy 0.914:2.134 190
+## 2 NA::a 9.996 2
+## 3 NA::b 9.997:9.999 0
## [1] "The variable HWTGWTK was recoded into HWTGWTK for the database cchs2010 the following recodes were made:"
-## valueTo From rowsRecoded
-## 1 copy 27.0:135.0 185
-## 2 NA::a 999.96 0
-## 3 NA::b 999.97:999.99 0
+## # A tibble: 3 x 3
+## valueTo From rowsRecoded
+## <chr> <chr> <int>
+## 1 copy 27.0:135.0 185
+## 2 NA::a 999.96 0
+## 3 NA::b 999.97:999.99 0
Since derived variables are based on previously transformed variables, if you want to only transform your derived variable, you must also specify its base CCHS variables in RecWTable()
as shown above. So for the derived BMI variable, you will have to also specify the height (HWTGHTM
) and weight (HWTGWTK
) variables.
Using bind_rows()
, you can then combine your transformed datasets.
@@ -232,22 +235,26 @@
Example 2. Transform a single variable from multiple CCHS datasets-This example shows how you can transform and combine a variable across multiple CCHS cycles. The sex variable in CCHS 2001 (
This example shows how you can transform and combine a variable across multiple CCHS cycles. The sex variable in CCHS 2001 (
-
-
Details+ +The categories in the grouped age variable (DHHGAGE) vary between CCHS cycles. As such, + a continous age variable (DHHGAGE_cont) was created that harmonized age across all CCHS cycle + by taking the midpoint of each age category. + + +Smoking pack-years
-
@@ -180,11 +182,13 @@ This function creates a derived variable (Pack_years_der) that measures an individual smoking pack-years - based on various CCHS smoking variables. This is a popular variable used by researchers to quantify lifetime exposure to cigarette use. +This function creates a derived variable (Pack_years_der) that measures an + individual's smoking pack-years based on various CCHS smoking variables. This is a popular + variable used by researchers to quantify lifetime exposure to cigarette use. ArgSMK_09A_B |
- |
+ number of years since quitting smoking. Variable asked to former daily smokers who quit <3 years ago. number of years since quitting smoking. Variable asked to former daily smokers +who quit <3 years ago. SMKG09C |
- |
+ number of years since quitting smoking. Variable asked to former daily smokers who quit >=3 years ago. number of years since quitting smoking. Variable asked to former daily smokers who +quit >=3 years ago. SMKG203_cont |
@@ -226,24 +230,31 @@ ValueDetails-pack-years is calculated by multiplying the number of cigarette packs per day (20 cigarettes per pack) by the number of years. - Example 1: a respondent who is a current smoker who smokes 1 package of cigarettes for the last 10 years has smoked 10 pack-years. - Pack-years is also calculated for former smokers. Example 2: a respondent who started smoking at age 20 years and smoked half - a pack of cigarettes until age 40 years smoked for 10 pack-years. +pack-years is calculated by multiplying the number of cigarette packs per day + (20 cigarettes per pack) by the number of years. Example 1: a respondent who is a current smoker + who smokes 1 package of cigarettes for the last 10 years has smoked 10 pack-years. + Pack-years is also calculated for former smokers. Example 2: a respondent who started smoking + at age 20 years and smoked half a pack of cigarettes until age 40 years smoked for + 10 pack-years. Examples
SDCGCBG |
- |
+ whether or not someone was born in Canada (1 - born in Canada, 2 - born outside Canada) whether or not someone was born in Canada (1 - born in Canada, 2 - born outside +Canada) SDCGRES |
- |
+ how long someone has lived in Canada. Note in the PUMF CCHS datasets, this is a categorical variable -with two categories (1 - 0-9 years; 2 - 10+ years). how long someone has lived in Canada. Note in the PUMF CCHS datasets, this is a +categorical variable with two categories (1 - 0-9 years; 2 - 10+ years). Value-Numeric value that is a fraction between 0 and 1 that represents percentage of a respondent's time in Canada +Numeric value that is a fraction between 0 and 1 that represents percentage of a + respondent's time in Canada Note-Since SDCGRES is a categorical variable measuring length of time, we've set midpoints in the function. A respondent - identified as being in Canada for 0-9 years is assigned a value of 4.5 years, and someone who has been in Canada for over 10 years - is assigned a value of 15 years. +Since SDCGRES is a categorical variable measuring length of time, we've set midpoints in + the function. A respondent identified as being in Canada for 0-9 years is assigned a value of + 4.5 years, and someone who has been in Canada for over 10 years is assigned a value of 15 years. Examples
2003 CCHS data
-
@@ -168,7 +168,9 @@ This is a subset of 200 observations from the 2003 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2003 cycle of the Canadian Community +Health Survey (CCHS) Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by +Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2003-c2-1-General File +See the open licensehere. + +Long name: cchs-82M0013-E-2003-c2-1-General File Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2005.html b/docs/reference/cchs2005.html index 13168e7b..e2229cf9 100644 --- a/docs/reference/cchs2005.html +++ b/docs/reference/cchs2005.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2005 CCHS data
-
@@ -168,7 +168,9 @@ This is a subset of 200 observations from the 2005 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2005 cycle of the Canadian Community Health Survey +(CCHS) Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by +Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2005-c3-1-main-file +See the open license here. + +Long name: cchs-82M0013-E-2005-c3-1-main-file Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2007_2008.html b/docs/reference/cchs2007_2008.html index aa519b46..fa7ff044 100644 --- a/docs/reference/cchs2007_2008.html +++ b/docs/reference/cchs2007_2008.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2007-2008 CCHS data
-
@@ -168,7 +168,8 @@ This is a subset of 200 observations from the 2007-2008 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2007-2008 cycle of the Canadian Community Health +Survey (CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: cchs-E-2007-2008-AnnualComponent +See the open license here. +Long name: cchs-E-2007-2008-AnnualComponent Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2009_2010.html b/docs/reference/cchs2009_2010.html index 10c7645b..39a3e6c4 100644 --- a/docs/reference/cchs2009_2010.html +++ b/docs/reference/cchs2009_2010.html @@ -41,8 +41,9 @@ - + @@ -76,7 +77,7 @@ @@ -147,8 +148,9 @@2009-2010 CCHS data
-
@@ -166,7 +168,7 @@ This is a subset of 200 observations from the 2009-2010 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. +This is a subset of 200 observations from the 2009-2010 cycle of the Canadian Community +Health Survey (CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-See the Statistics Canada Open License here. +See the open license here. Long name: CCHS-82M0013-E-2009-2010-Annualcomponent Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2010.html b/docs/reference/cchs2010.html index 5f1c8a21..9b3c5c54 100644 --- a/docs/reference/cchs2010.html +++ b/docs/reference/cchs2010.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2010 CCHS data
-
@@ -168,7 +168,8 @@ This is a subset of 200 observations from the 2010 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2010 cycle of the Canadian Community Health Survey +(CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: CCHS-82M0013-E-2010-AnnualComponent +See the open license here. +Long name: CCHS-82M0013-E-2010-AnnualComponent Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2011_2012.html b/docs/reference/cchs2011_2012.html index ba060b7c..003bdf1b 100644 --- a/docs/reference/cchs2011_2012.html +++ b/docs/reference/cchs2011_2012.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2011-2012 CCHS data
-
@@ -168,7 +168,9 @@ This is a subset of 200 observations from the 2011-2012 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2011-2012 cycle of the Canadian Community Health +Survey (CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2011-2012-Annual-component +See the open license here. + +Long name: cchs-82M0013-E-2011-2012-Annual-component Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2012.html b/docs/reference/cchs2012.html index 7535ab24..58a190ff 100644 --- a/docs/reference/cchs2012.html +++ b/docs/reference/cchs2012.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2012 CCHS data
-
@@ -168,7 +168,8 @@ This is a subset of 200 observations from the 2012 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2012 cycle of the Canadian Community Health Survey +(CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2012-Annual-component +See the open license here. +Long name: cchs-82M0013-E-2012-Annual-component Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2013_2014.html b/docs/reference/cchs2013_2014.html index 923613d9..757ecc87 100644 --- a/docs/reference/cchs2013_2014.html +++ b/docs/reference/cchs2013_2014.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2013-2014 CCHS data
-
@@ -168,7 +168,8 @@ This is a subset of 200 observations from the 2013-2014 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2013-2014 cycle of the Canadian Community Health +Survey (CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2013-2014-Annual-component +See the open license here. +Long name: cchs-82M0013-E-2013-2014-Annual-component Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/cchs2014.html b/docs/reference/cchs2014.html index b8df691b..f75c1409 100644 --- a/docs/reference/cchs2014.html +++ b/docs/reference/cchs2014.html @@ -41,9 +41,9 @@ - + @@ -77,7 +77,7 @@ @@ -148,9 +148,9 @@2014 CCHS data
-
@@ -168,7 +168,8 @@ This is a subset of 200 observations from the 2014 cycle of the Canadian Community Health Survey (CCHS) -Public Use Microdata file (PUMF) dataset. The CCHS survey is conducted by Statistics Canada. -See the Statistics Canada Open License here. +This is a subset of 200 observations from the 2014 cycle of the Canadian Community Health Survey +(CCHS) Public Use Microdata file (PUMF) dataset. +The CCHS survey is conducted by Statistics Canada. ValueDetails-Long name: cchs-82M0013-E-2014-Annual-component +See the open license here. +Long name: cchs-82M0013-E-2014-Annual-component Additional documentation (PDFs): https://osf.io/hkuy3/ diff --git a/docs/reference/ifelse2.html b/docs/reference/ifelse2.html index 8a09d724..598bf7f0 100644 --- a/docs/reference/ifelse2.html +++ b/docs/reference/ifelse2.html @@ -75,7 +75,7 @@ diff --git a/docs/reference/index.html b/docs/reference/index.html index ec2ac318..d13d8303 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -73,7 +73,7 @@ @@ -229,6 +229,12 @@Resp_condition_fun3()
Resp_condition_fun3 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ + | +Derived categorical age |
||||||||||||||||||||||