Skip to content

Commit 492f4b3

Browse files
committed
Merge branch 'master' of https://github.com/dias-bruno/ActiveCA
2 parents 0d7e064 + db66b7f commit 492f4b3

17 files changed

+1326
-14
lines changed

R/ActiveCA-package.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ NULL
728728
#' \item{LUC_RST}{Population centres indicator.}
729729
#' \item{GTU_110}{How often do you feel rushed? Would you say it is:.}
730730
#' \item{GTU_130}{How often do you feel you have time on your hands that you Don't know what to do with? Would you say it is:.}
731+
#' \item{SLM_01}{Using a scale of 0 to 10 where 0 means "Very dissatisfied" and 10 means "Very satisfied", how do you feel about your life as a whole right now?}
732+
#' \item{SRH_110}{In general, would you say your health is...?}
733+
#' \item{SRH_150}{In general, would you say your mental health is...?}
731734
#' \item{DVTDAY}{Type of day of the designated day of interview.}
732735
#'}
733736
#' @docType data

data-raw/01-preprocessing-episode-files.Rmd

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,13 @@ Read the Episode and Main files of the 2015 GSS survey:
232232

233233
```{r}
234234
# Episode File
235-
gss_e_2015 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2015/gss-e.csv"))
235+
#gss_e_2015 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2015/gss-e.csv"))# Original file
236+
gss_e_2015 <- read.csv(paste0(here(), "/data-raw/2015-gss-e-reproducibility.csv")) # Subset for reproducibility
237+
236238
237239
# Main File
238-
gss_m_2015 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2015/gss-m.csv"))
240+
#gss_m_2015 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2015/gss-m.csv")) # Original file
241+
gss_m_2015 <- read.csv(paste0(here(), "/data-raw/2015-gss-m-reproducibility.csv")) # Subset for reproducibility
239242
```
240243

241244
### Walking 2015
@@ -627,10 +630,12 @@ Read the Episode and Main files of the 2010 GSS survey:
627630

628631
```{r}
629632
# Episode File
630-
gss_e_2010 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2010/gss-12M0018-E-2010-c-24-tus-ef_F1.csv"))
633+
#gss_e_2010 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2010/gss-12M0018-E-2010-c-24-tus-ef_F1.csv")) # Original file
634+
gss_e_2010 <- read.csv(paste0(here(), "/data-raw/2010-gss-e-reproducibility.csv")) # Subset for reproducibility
631635
632636
# Main File
633-
gss_m_2010 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2010/gss-12M0018-E-2010-c-24-tus-mf_F1.csv"))
637+
#gss_m_2010 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2010/gss-12M0018-E-2010-c-24-tus-mf_F1.csv")) # Original file
638+
gss_m_2010 <- read.csv(paste0(here(), "/data-raw/2010-gss-m-reproducibility.csv")) # Subset for reproducibility
634639
```
635640

636641
### Walking 2010
@@ -776,7 +781,6 @@ walking_2010 |>
776781
See `RECID` == 3 and check the walking episode:
777782

778783
```{r}
779-
780784
gss_e_2010 %>%
781785
filter(RECID == 3) %>%
782786
slice(unique(c(reduce(map(which(PLACE == 14), ~ c(.x - 1, .x, .x + 1)), c)))) %>%
@@ -1095,10 +1099,13 @@ Read the Episode and Main files of the 2005 GSS survey:
10951099

10961100
```{r}
10971101
# Episode File
1098-
gss_e_2005 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2005/gss-12M0019-E-2005-c-19-e_F1.csv"))
1102+
#gss_e_2005 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2005/gss-12M0019-E-2005-c-19-e_F1.csv")) # Original file
1103+
gss_e_2005 <- read.csv(paste0(here(), "/data-raw/2005-gss-e-reproducibility.csv")) # Subset for reproducibility
1104+
10991105
11001106
# Main File
1101-
gss_m_2005 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2005/gss-12M0019-E-2005-c-19-m_F1.csv"))
1107+
#gss_m_2005 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-2005/gss-12M0019-E-2005-c-19-m_F1.csv")) # Original file
1108+
gss_m_2005 <- read.csv(paste0(here(), "/data-raw/2005-gss-m-reproducibility.csv")) # Subset for reproducibility
11021109
```
11031110

11041111
### Walking 2005
@@ -1556,10 +1563,12 @@ Read the Episode and Main files of the 1998 GSS survey:
15561563

15571564
```{r}
15581565
# Episode File
1559-
gss_e_1998 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1998/gss-12M0012-E-1998-c-12e_F1.csv"))
1566+
# gss_e_1998 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1998/gss-12M0012-E-1998-c-12e_F1.csv")) # Original file
1567+
gss_e_1998 <- read.csv(paste0(here(), "/data-raw/1998-gss-e-reproducibility.csv")) # Subset for reproducibility
15601568
15611569
# Main File
1562-
gss_m_1998 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1998/gss-12M0012-E-1998-c-12-m_F1.csv"))
1570+
# gss_m_1998 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1998/gss-12M0012-E-1998-c-12-m_F1.csv")) # Original file
1571+
gss_m_1998 <- read.csv(paste0(here(), "/data-raw/1998-gss-m-reproducibility.csv")) # Subset for reproducibility
15631572
```
15641573

15651574

@@ -1947,10 +1956,12 @@ Read the Episode and Main files of the 1992 GSS survey:
19471956

19481957
```{r}
19491958
# Episode File
1950-
gss_e_1992 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1992/gss-12M0007-E-1992-c-7-ep_F1.csv"))
1959+
# gss_e_1992 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1992/gss-12M0007-E-1992-c-7-ep_F1.csv")) # Original file
1960+
gss_e_1992 <- read.csv(paste0(here(), "/data-raw/1992-gss-e-reproducibility.csv")) # Subset for reproducibility
19511961
19521962
# Main File
1953-
gss_m_1992 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1992/gss-12M0007-E-1992-c-7-m_F1.csv"))
1963+
# gss_m_1992 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1992/gss-12M0007-E-1992-c-7-m_F1.csv")) # Original file
1964+
gss_m_1992 <- read.csv(paste0(here(), "/data-raw/1992-gss-m-reproducibility.csv")) # Subset for reproducibility
19541965
```
19551966

19561967
### Walking 1992
@@ -2344,10 +2355,12 @@ Read the Episode and Main files of the 1986 GSS survey:
23442355

23452356
```{r}
23462357
# Episode File
2347-
gss_e_1986 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1986/gss-12M0002-E-1986-c-2-ep_F1.csv"))
2358+
# gss_e_1986 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1986/gss-12M0002-E-1986-c-2-ep_F1.csv")) # Original file
2359+
gss_e_1986 <- read.csv(paste0(here(), "/data-raw/1986-gss-e-reproducibility.csv")) # Subset for reproducibility
23482360
23492361
# Main File
2350-
gss_m_1986 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1986/gss-12M0002-E-1986-c-2-main_F1.csv"))
2362+
# gss_m_1986 <- read.csv(paste0(here(), "/data-raw/source-files/Time-use-1986/gss-12M0002-E-1986-c-2-main_F1.csv")) # Original file
2363+
gss_m_1992 <- read.csv(paste0(here(), "/data-raw/1986-gss-m-reproducibility.csv")) # Subset for reproducibility
23512364
```
23522365

23532366
### Walking 1986

data-raw/03-preprocessing-main-files.Rmd

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Select only the socioeconomic variables:
130130

131131
```{r filtering-variables-2015}
132132
gss_main_2015 <- gss_m_2015 %>%
133-
select(PUMFID:DVTDAY)
133+
select(PUMFID:DVTDAY, SLM_01, SRH_110, SRH_115)
134134
```
135135

136136
Labeling socioeconomic variables:
@@ -647,6 +647,87 @@ gss_main_2015 <- gss_main_2015 %>%
647647
summary(gss_main_2015$GTU_130)
648648
```
649649

650+
```{r SLM_01-2015}
651+
values_ordered <- c("10 - Very satisfied","9","8","7","6","5",
652+
"4","3","2","1","0 - Very dissatisfied",
653+
"Valid skip",
654+
"Don’t know",
655+
"Refusal",
656+
"Not stated")
657+
658+
gss_main_2015 <- gss_main_2015 %>%
659+
mutate( # SLM_01: Using a scale of 0 to 10 where 0 means "Very dissatisfied" and 10 means "Very satisfied",how do you feel about your life as a whole right now?
660+
SLM_01 =
661+
case_when(SLM_01 == 0 ~ "0 - Very dissatisfied",
662+
SLM_01 == 1 ~ "1",
663+
SLM_01 == 2 ~ "2",
664+
SLM_01 == 3 ~ "3",
665+
SLM_01 == 4 ~ "4",
666+
SLM_01 == 5 ~ "5",
667+
SLM_01 == 6 ~ "6",
668+
SLM_01 == 7 ~ "7",
669+
SLM_01 == 8 ~ "8",
670+
SLM_01 == 9 ~ "9",
671+
SLM_01 == 10 ~ "10 - Very satisfied",
672+
SLM_01 == 96 ~ "Valid skip",
673+
SLM_01 == 97 ~ "Don’t know",
674+
SLM_01 == 98 ~ "Refusal",
675+
SLM_01 == 99 ~ "Not stated"),
676+
SLM_01 = factor(SLM_01, levels = rev(values_ordered), ordered = TRUE))
677+
678+
summary(gss_main_2015$SLM_01)
679+
```
680+
681+
```{r SRH_110-2015}
682+
values_ordered <- c("Excellent","Very good","Good",
683+
"Fair","Poor",
684+
"Valid skip",
685+
"Don’t know",
686+
"Refusal",
687+
"Not stated")
688+
689+
gss_main_2015 <- gss_main_2015 %>%
690+
mutate( # SRH_110: In general, would you say your health is...?
691+
SRH_110 =
692+
case_when(SRH_110 == 1 ~ "Excellent",
693+
SRH_110 == 2 ~ "Very good",
694+
SRH_110 == 3 ~ "Good",
695+
SRH_110 == 4 ~ "Fair",
696+
SRH_110 == 5 ~ "Poor",
697+
SRH_110 == 6 ~ "Valid skip",
698+
SRH_110 == 7 ~ "Don’t know",
699+
SRH_110 == 8 ~ "Refusal",
700+
SRH_110 == 9 ~ "Not stated"),
701+
SRH_110 = factor(SRH_110, levels = rev(values_ordered), ordered = TRUE))
702+
703+
summary(gss_main_2015$SRH_110)
704+
```
705+
706+
```{r SRH_115-2015}
707+
values_ordered <- c("Excellent","Very good","Good",
708+
"Fair","Poor",
709+
"Valid skip",
710+
"Don’t know",
711+
"Refusal",
712+
"Not stated")
713+
714+
gss_main_2015 <- gss_main_2015 %>%
715+
mutate( # SRH_115: In general, would you say your mental health is...?
716+
SRH_115 =
717+
case_when(SRH_115 == 1 ~ "Excellent",
718+
SRH_115 == 2 ~ "Very good",
719+
SRH_115 == 3 ~ "Good",
720+
SRH_115 == 4 ~ "Fair",
721+
SRH_115 == 5 ~ "Poor",
722+
SRH_115 == 6 ~ "Valid skip",
723+
SRH_115 == 7 ~ "Don’t know",
724+
SRH_115 == 8 ~ "Refusal",
725+
SRH_115 == 9 ~ "Not stated"),
726+
SRH_115 = factor(SRH_115, levels = rev(values_ordered), ordered = TRUE))
727+
728+
summary(gss_main_2015$SRH_115)
729+
```
730+
650731
```{r DVTDAY-2015}
651732
gss_main_2015 <- gss_main_2015 %>%
652733
mutate( # DVTDAY: Diary - Reference day - Type
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"","SEQNUM","DDAY","NO_EPISO","ACT_CODE","STRTTIME","ENDTIME","DURATION","PLACE","ALONE","SPOUSE","CHILD","OTH_FAM","FRIENDS","OTHERS","REFFLAG","FWGT_MS"
2+
"1",11805,4,19,36,1550,1610,20,3,2,2,2,2,2,1,0,5690238
3+
"2",12273,1,11,91,1840,2330,290,1,1,2,2,2,2,2,0,5264075
4+
"3",14962,5,22,17,2045,2130,45,5,1,2,2,2,2,2,0,44447233
5+
"4",4436,4,11,76,2230,2800,330,3,2,2,2,2,1,1,0,20901730
6+
"5",8884,4,13,43,830,840,10,1,1,2,2,2,2,2,0,3324810
7+
"6",15093,4,16,10,1030,1300,150,1,1,2,2,2,2,2,0,17617961
8+
"7",8179,3,30,12,2003,2015,12,1,1,2,2,2,2,2,0,11958140
9+
"8",9385,1,22,79,1355,1400,5,5,2,2,2,1,2,2,0,37265843
10+
"9",7249,2,30,59,740,800,20,6,1,2,2,2,2,2,0,30639535
11+
"10",11617,4,22,39,1545,1600,15,5,1,2,2,2,2,2,0,10481979
12+
"11",10702,2,17,39,1630,1635,5,5,1,2,2,2,2,2,0,6755590
13+
"12",13911,3,27,30,1445,1530,45,3,2,2,2,1,2,2,0,16560436
14+
"13",14026,7,13,45,2315,2800,285,1,0,0,0,0,0,0,0,10764198
15+
"14",13043,6,22,10,1220,1300,40,1,1,2,2,2,2,2,0,23962239
16+
"15",4509,3,18,11,1200,1230,30,1,2,1,2,2,2,2,0,11247990
17+
"16",60,2,13,42,820,1230,250,3,1,2,2,2,2,2,0,12323488
18+
"17",7170,2,15,75,1300,1500,120,3,2,2,2,2,1,2,0,11548930
19+
"18",325,6,22,91,2130,2245,75,1,1,2,2,2,2,2,0,27759881
20+
"19",914,5,10,59,1500,1510,10,5,1,2,2,2,2,2,0,19534982
21+
"20",14697,3,20,86,2205,2330,85,3,2,2,2,2,1,2,0,21032872
22+
"21",908,4,27,50,1005,1100,55,3,2,2,2,2,2,1,0,12042016
23+
"22",9889,7,23,53,1455,1530,35,3,1,2,2,2,2,2,0,8794965
24+
"23",9678,4,18,12,1830,1930,60,1,2,2,1,2,2,2,0,4001224
25+
"24",12859,4,26,33,1240,1245,5,3,1,2,2,2,2,2,0,9566637
26+
"25",8534,1,18,95,1250,1255,5,3,2,2,2,2,1,2,0,30573445
27+
"26",6897,1,24,40,1000,1030,30,1,0,0,0,0,0,0,0,13451668
28+
"27",10685,7,18,91,2050,2250,120,3,2,2,2,2,1,2,0,14384018
29+
"28",4766,5,20,66,1730,2200,270,2,2,2,2,2,1,1,0,24178119
30+
"29",9183,2,28,59,1020,1035,15,5,1,2,2,2,2,2,0,21753352
31+
"30",7255,2,21,59,2030,2050,20,5,2,2,2,2,1,2,0,20467307
32+
"31",15896,2,20,79,2000,2002,2,5,2,1,2,2,2,2,0,6674830
33+
"32",7046,2,25,49,2030,2033,3,5,1,2,2,2,2,2,0,9107429
34+
"33",7370,7,23,39,1230,1245,15,5,2,1,1,2,2,2,0,17940329
35+
"34",5911,4,14,79,1300,1310,10,5,1,2,2,2,2,2,0,16780894
36+
"35",8493,4,25,43,1230,1330,60,1,2,2,2,2,2,1,0,3986098
37+
"36",11826,5,56,79,2310,2320,10,5,1,2,2,2,2,2,0,5907700
38+
"37",3491,1,13,1,1600,2300,420,2,2,2,2,2,2,1,0,27057383
39+
"38",11339,4,20,33,1600,1610,10,3,2,2,2,2,2,1,0,7168766
40+
"39",9889,7,23,51,1000,1145,105,3,2,2,2,2,2,1,0,8794965
41+
"40",12511,4,24,1,900,1000,60,2,2,2,2,2,2,1,0,22014150
42+
"41",5847,6,32,21,2010,2020,10,1,2,1,1,2,2,2,0,22477198
43+
"42",4806,2,21,50,1035,1200,85,3,2,2,2,2,2,1,0,4418051
44+
"43",10662,3,17,44,1600,1630,30,5,9,9,9,9,9,9,0,3669171
45+
"44",12345,5,22,1,1400,1700,180,2,2,2,2,2,2,1,0,16303322
46+
"45",2580,2,30,33,1007,1040,33,3,2,2,2,2,1,2,0,6367883
47+
"46",12663,1,13,79,1230,1235,5,5,1,2,2,2,2,2,0,10556333
48+
"47",3207,4,24,75,1220,1600,220,3,2,2,2,2,1,2,0,24537200
49+
"48",12613,6,23,40,1830,1900,30,1,0,0,0,0,0,0,0,15498115
50+
"49",5155,6,12,1,1230,1700,270,2,2,2,2,2,2,1,0,5569572
51+
"50",1874,6,21,12,900,905,5,5,1,2,2,2,2,2,0,2953659
52+
"51",5723,5,20,39,1600,1640,40,5,1,2,2,2,2,2,0,32954479
53+
"52",13222,4,21,91,1625,1730,65,1,2,2,1,2,2,2,0,5225960
54+
"53",10329,7,25,69,1445,1500,15,5,1,2,2,2,2,2,0,31952590
55+
"54",5575,4,20,79,1830,1915,45,5,2,2,2,1,2,2,0,18716825
56+
"55",16032,7,21,45,2635,2800,85,1,0,0,0,0,0,0,0,10018116
57+
"56",16244,7,13,75,1810,2345,335,3,2,2,2,2,1,2,0,36797023
58+
"57",5878,4,27,32,1900,2040,100,3,2,2,2,2,1,1,0,5422841
59+
"58",15081,2,15,44,1800,1830,30,3,1,2,2,2,2,2,0,6514255
60+
"59",5768,6,18,82,540,550,10,5,1,2,2,2,2,2,0,38577713
61+
"60",2436,7,19,49,1700,1730,30,5,1,2,2,2,2,2,0,21819311
62+
"61",2031,4,14,43,1200,1230,30,1,2,1,2,2,2,2,0,6174168
63+
"62",93,5,17,43,1235,1315,40,1,2,2,2,1,2,2,0,15279047
64+
"63",10888,6,13,90,940,1200,140,1,1,2,2,2,2,2,0,17221230
65+
"64",2193,5,16,49,1900,1930,30,5,2,2,2,2,1,2,0,12965126
66+
"65",151,4,26,79,815,820,5,5,1,2,2,2,2,2,0,9055781
67+
"66",15953,1,16,69,1200,1210,10,5,9,9,9,9,9,9,0,37854173
68+
"67",4059,5,30,79,1230,1235,5,5,1,2,2,2,2,2,0,19089798
69+
"68",619,4,14,43,2105,2130,25,1,2,1,1,2,2,2,0,22001126
70+
"69",10481,2,23,39,1615,1630,15,5,1,2,2,2,2,2,0,14721224
71+
"70",8317,5,19,17,830,1030,120,1,1,2,2,2,2,2,0,35161700
72+
"71",4483,1,17,30,1115,1145,30,3,1,2,2,2,2,2,0,14282649
73+
"72",72,4,17,29,730,800,30,5,2,2,1,2,2,2,0,6992040
74+
"73",3114,5,24,91,945,1100,75,1,1,2,2,2,2,2,0,17029072
75+
"74",7050,1,19,28,920,1130,130,3,2,2,2,1,2,2,0,9922052
76+
"75",11354,3,17,13,1505,1515,10,1,2,2,1,2,2,2,0,12930386
77+
"76",3878,7,8,9,1730,1900,90,5,1,2,2,2,2,2,0,12625885
78+
"77",5422,5,15,50,830,1430,360,3,2,2,2,2,1,1,0,64134466
79+
"78",10170,1,14,9,1015,1030,15,5,1,2,2,2,2,2,0,34369891
80+
"79",11402,6,19,6,635,700,25,2,2,2,2,2,1,2,0,21161952
81+
"80",8387,4,18,40,955,1030,35,1,0,0,0,0,0,0,0,16101589
82+
"81",4816,3,24,43,1735,1755,20,1,2,1,2,2,2,2,0,8291367
83+
"82",4651,3,17,69,720,730,10,5,1,2,2,2,2,2,0,9079252
84+
"83",3380,7,20,79,1600,1605,5,5,2,2,2,2,1,2,0,21289783
85+
"84",15828,3,24,17,1230,1315,45,5,1,2,2,2,2,2,0,14601374
86+
"85",13313,6,25,30,1100,1120,20,3,1,2,2,2,2,2,0,9607957
87+
"86",7339,3,36,9,1200,1205,5,5,2,2,2,2,2,1,0,6725442
88+
"87",10172,2,32,9,2040,2045,5,5,1,2,2,2,2,2,0,4083548
89+
"88",9728,5,17,9,845,900,15,5,1,2,2,2,2,2,0,16477239
90+
"89",10008,4,20,39,1030,1045,15,5,1,2,2,2,2,2,0,12540759
91+
"90",2784,3,17,50,1345,1515,90,3,2,2,2,2,2,1,0,32698571
92+
"91",11394,6,33,79,2000,2015,15,5,2,2,2,2,1,2,0,13304464
93+
"92",1124,3,20,44,1200,1230,30,2,2,2,2,2,2,1,0,11624693
94+
"93",7901,7,32,33,1425,1450,25,3,2,2,1,2,2,2,0,17741485
95+
"94",9205,3,15,46,1632,1830,118,1,0,0,0,0,0,0,0,8090487
96+
"95",6189,7,12,38,800,1100,180,5,2,1,2,2,2,2,0,15923279
97+
"96",2963,3,24,39,1330,1335,5,5,1,2,2,2,2,2,0,11386683
98+
"97",14459,1,20,1,1330,1530,120,2,2,2,2,2,2,1,0,7094569
99+
"98",9582,7,20,79,1435,1450,15,5,2,2,2,1,1,2,0,35064437
100+
"99",5071,6,23,91,2215,2235,20,1,2,1,2,2,2,2,0,30528134
101+
"100",249,2,15,40,700,730,30,1,0,0,0,0,0,0,0,13361324

0 commit comments

Comments
 (0)