Warning: package 'kableExtra' was built under R version 4.2.3
Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':
group_rows
Warning: package 'officer' was built under R version 4.2.3
Attaching package: 'car'
The following object is masked from 'package:dplyr':
recode
The following object is masked from 'package:purrr':
some
Attaching package: 'magrittr'
The following object is masked from 'package:purrr':
set_names
The following object is masked from 'package:tidyr':
extract
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
Attaching package: 'MASS'
The following object is masked from 'package:dplyr':
select
Attaching package: 'survey'
The following object is masked from 'package:graphics':
dotchart
Attaching package: 'srvyr'
The following object is masked from 'package:MASS':
select
The following object is masked from 'package:kableExtra':
group_rows
The following object is masked from 'package:stats':
filter
Attaching package: 'survminer'
The following object is masked from 'package:survival':
myeloma
Warning: package 'gt' was built under R version 4.2.2
Attaching package: 'gtsummary'
The following object is masked from 'package:MASS':
select
Warning: package 'flextable' was built under R version 4.2.3
Attaching package: 'flextable'
The following objects are masked from 'package:gtsummary':
as_flextable, continuous_summary
The following objects are masked from 'package:ggpubr':
border, font, rotate
The following objects are masked from 'package:kableExtra':
as_image, footnote
The following object is masked from 'package:purrr':
compose
Please cite as:
Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
# List of variables to checkvariables_to_check <-c("h4ma1","h3ma1","h3ma2","h3ma3","h4ma3","h3ma4","h4ma5","h3od38","h3od33","h3ma5","h3od33","h3ma6","h3id15","h4id5h")# Check if variables exist in dataframe Fvariables_exist <- variables_to_check %in%colnames(w3)# Print the resultprint(variables_exist)
# Year of survey for wave 3#summary(w3$iyear3)#year of birth#summary(w3$h3od1y)# Current age: year of survey minus age at birthw3$age <- (w3$iyear3 -w3$h3od1y)summary(w3$age)
Min. 1st Qu. Median Mean 3rd Qu. Max.
18.0 21.0 22.0 22.2 24.0 28.0
# Year of survey for wave 4#summary(w4$iyear4)#year of birth#summary(w4$h4od1y)# Current age is year of survey minus age at birthw4$age <- (w4$iyear4 -w4$h4od1y)summary(w4$age)
Min. 1st Qu. Median Mean 3rd Qu. Max.
25 28 29 29 30 34
#Current age: year of survey minus age at birthw5$age <- (w5$iyear5 -w5$h5od1y)summary(w5$age)
Min. 1st Qu. Median Mean 3rd Qu. Max.
33.00 36.00 37.00 37.32 39.00 42.00
#Employment status#h3da28: Do you currently have a job?#w3$empstat<- car::Recode(w3$h3da28,recodes="1=1; 0=0; else=NA")#H4LM11: Do you currently work 10 hours per week?w4$empstat<- car::Recode(w4$h4lm11,recodes="1='Employed'; 0='Unemployed'; else=NA")#Race/Ethnicityw3$hisp <- car::Recode(w3$h3od2, recodes ="1= 'Hisp_' ; 0= 'NH_'; else=NA")w3$race <- car::Recode(w3$h3ir4, recodes ="1= 'White'; 2= 'Black'; 3 = 'Asian'; 4='Other'; else=NA")w3$race_eth<-ifelse(w3$hisp ==1, "hisp", w3$race)w3$race_eth <-interaction(w3$hisp, w3$race) w3$race_ethr<-mutate(w3, ifelse(hisp==0& race==1, 1,ifelse(hisp==0& race==2, 2,ifelse(hisp==1, 3,ifelse(hisp==0& race==3, 4,ifelse(hisp==0& race==4, 5, "NA"))))))w3$race_ethr<-ifelse(substr(w3$race_eth, 1, 4)=="hisp", "hisp", as.character(w3$race_eth))#Education#What is the highest grade or year of regular school you have completed?w3$educ <- car::Recode(w3$h3ed1, recodes ="6:12= 'upto HS' ; 13:22= 'higher than HS'; else=NA")w4$educ <- car::Recode(w4$h4ed2, recodes ="1:3 = 'upto to HS'; 4:13 = 'higher than HS'; else = NA")
Depression
# Depression## h3id15: Have you ever been diagnosed with depression##h4id5h: Has a doctor, nurse or other health care provider ever told you that you have or had: depression?w3$dep1 <- car::Recode(w3$h3id15,recodes="1='1'; 0='2'; else='3'")w4$dep2 <- car::Recode(w4$h4id5h,recodes="1='1'; 0='2'; else='3'")