library(restatapi) library(data.table) library(ggplot2) library(chron) yr<-"2010" eu_ctry_names<-do.call(rbind,lapply(get("cc",envir=.restatapi_env)$EU28,search_eurostat_dsd,dsd=get_eurostat_dsd("tus_00age"),exact_match=TRUE))$name eu_ctry_names<-gsub(" \\(.*\\)","",eu_ctry_names) #dt<-get_eurostat_data("tus_00age",filters=list(unit="spent",age="total",sex="total",acl00="^(?!total).*$",geo="be"),date_filter=2010,label=F,ignore.case=T,exact_match=F,force_local_filter=T,perl=T) #dt<-get_eurostat_data("tus_00age",filters=list(unit="spent",age="total",sex="total",acl00=c("ac01","ac02","ac03","ac1a","ac1b","ac2$","ac3$","ac4-8$","ac9a"),geo="be"),date_filter=2010,label=T,ignore.case=T,exact_match=F,force_local_filter=T,perl=T) #dt<-get_eurostat_data("tus_00age",filters=list(unit="spent",age="total",sex="total",geo="be"),date_filter=2010,label=T,ignore.case=T,exact_match=F,force_local_filter=T,perl=T) dt<-get_eurostat_data("tus_00age",filters=list(unit="spent",age="total",sex="total",acl00=c("sleep","eat","^employ"," (family|personal) care","^leisure","^study","except travel")),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T) dt dt<-get_eurostat_data("tus_00age",filters=list(unit="spent",age="total",sex="total",acl00=c("sleep","eat","^employ"," (family|personal) care","^leisure","^study","except travel")),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))] dt<-dt[,c("acl00","geo","values")] sdt<-dt[grepl("(ating|ther)",acl00),.(acl00="Eating and other personal care",values=sum(values)),by=geo] sdt dt<-rbind(dt[!grepl("(ating|ther)",acl00)],sdt) fig1_colors<-c("#F6A26B","#F06423","#71A8DF","#286EB4","#FDDBA3","#FCC975","#FAA519") ggplot(dt, aes(x=geo, y=values,fill=acl00)) + geom_bar(position="stack",stat="identity")+ scale_y_chron(format="%H:%M") + scale_fill_manual(values = fig1_colors)+ ggtitle("Figure 1") + ylab ("")+ xlab("")+ theme(axis.text.x = element_text(angle = 90, hjust = 1)) dt_sep<-data.table::data.table(acl00=c("Sleep","Sleep"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) acls_ord<-c('Travel except travel related to jobs','Leisure, social and associative life','Household and family care','Study','Employment, related activities and travel as part of/during main and second job','Eating and other personal care','Sleep') dt$acl00<-factor(dt$acl00,levels=acls_ord) geo_ord<-c('Belgium','Germany','Estonia','Greece','Spain','France','Italy','Luxembourg','Hungary','Netherlands','Austria','Poland','Romania','Finland','United Kingdom',' ','Norway',' ','Serbia','Turkey') dt$geo<-factor(dt$geo,levels=geo_ord) options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=acl00)) + theme_minimal() + geom_bar(position="stack",stat="identity",width=0.5)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,4/24)) + scale_fill_manual(values = fig1_colors)+ ggtitle("Figure 1: Mean time spent on daily activities, all individuals by country, (hh:mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank()) dt<-get_eurostat_data("tus_00age",filters=list(unit="Participation time",age="total",sex="total",acl00=c("^study","^empl")),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))] dt<-dt[,c("acl00","geo","values")] dt dt_sep<-data.table::data.table(acl00=c("Study","Study"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Empl",acl00)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia','Turkey') dt$geo<-factor(dt$geo,levels=geo_ord) fig2_colors<-c("#FAA519","#286EB4") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=acl00)) + theme_minimal() + geom_bar(position="dodge",stat="identity",width=0.7)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/24)) + scale_fill_manual(values = fig2_colors)+ ggtitle("Figure 2: Participation time per day in study and employment, only individuals taking part in the activity, by country, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00age",filters=list(unit="Participation time",age="total",acl00="household.*care"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))] dt<-dt[,c("sex","geo","values")] dt dt_sep<-data.table::data.table(sex=c("Males","Males"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Total",sex)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia','Turkey') dt$geo<-factor(dt$geo,levels=geo_ord) sex_ord<-c('Males','Females',"Total") dt$sex<-factor(dt$sex,levels=sex_ord) fig3_colors<-c("#FAA519","#286EB4","#F06423") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt[sex!="Total"], aes(fill=sex),position="dodge",stat="identity",width=0.6)+ geom_point(data=dt[grepl("Total",sex)],aes(shape=sex),colour="#F06423",fill="#F06423",size=3)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/24)) + scale_fill_manual(values = fig3_colors)+ scale_shape_manual(values=c("Males"=NA,"Females"=NA,"Total"=23))+ ggtitle("Figure 3: Participation time per day in household and family care, by gender, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="household.*care",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","geo","values")] dt dt_sep<-data.table::data.table(sex=c("Males","Males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Females",sex)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) sex_ord<-c('Males','Females') dt$sex<-factor(dt$sex,levels=sex_ord) fig4_colors<-c("#FAA519","#286EB4") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(aes(fill=sex),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig4_colors)+ scale_y_continuous(breaks=seq(0,100,10)) + ggtitle("Figure 4: Participation rate per day in household and family care,\n main activity, %, by gender (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^food|^clean",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Cleaning dwelling, males","Cleaning dwelling, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Food management except dish washing, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd),decreasing=TRUE) dt$bd<-factor(dt$bd,levels=bd_ord) fig5_colors<-c("#FAA519","#FCC975","#286EB4","#71A8DF") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig5_colors)+ scale_y_continuous(breaks=seq(0,100,10)) + ggtitle("Figure 5: Participation rate per day in cleaning and food management, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^iron|^laund",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Laundry, males","Laundry, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Laundry, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd),decreasing=TRUE) dt$bd<-factor(dt$bd,levels=bd_ord) fig6_colors<-c("#FAA519","#FCC975","#286EB4","#71A8DF") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig6_colors)+ scale_y_continuous(breaks=seq(0,40,5)) + ggtitle("Figure 6: Participation rate per day in laundry and ironing, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^shop",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Shopping and services, males","Shopping and services, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Shopping and services, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd),decreasing=TRUE) dt$bd<-factor(dt$bd,levels=bd_ord) fig7_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig7_colors)+ scale_y_continuous(breaks=seq(0,70,10)) + ggtitle("Figure 7: Participation rate per day in shopping and services, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^child|^teach",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Childcare, except teaching, reading and talking, males","Childcare, except teaching, reading and talking, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Childcare, except teaching, reading and talking, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia','Turkey') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd))[c(2,1,4,3)] dt$bd<-factor(dt$bd,levels=bd_ord) fig8_colors<-c("#FAA519","#FCC975","#286EB4","#71A8DF") options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig8_colors)+ scale_y_continuous(breaks=seq(0,35,5)) + ggtitle("Figure 8: Participation rate per day in childcare, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^const",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Construction and repairs, males","Construction and repairs, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Construction and repairs, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd),decreasing=TRUE) dt$bd<-factor(dt$bd,levels=bd_ord) fig9_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig9_colors)+ scale_y_continuous(limits=c(0,25),breaks=seq(0,25,5)) + ggtitle("Figure 9: Participation rate per day in construction, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ",filters=list(unit="Participation rate",age="total",acl00="^garden",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) dt<-dt[,c("sex","acl00","geo","values")] dt[,bd:=paste0(acl00,", ",tolower(sex))][,c("acl00","sex"):=NULL] dt dt_sep<-data.table::data.table(bd=c("Gardening; other pet care, males","Gardening; other pet care, males"),geo=c(" "," "),values=c(NA,NA)) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Gardening; other pet care, females",bd)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Turkey','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) bd_ord<-sort(unique(dt$bd),decreasing=TRUE) dt$bd<-factor(dt$bd,levels=bd_ord) fig10_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt, aes(fill=bd),position="dodge",stat="identity",width=0.6)+ scale_fill_manual(values = fig10_colors)+ scale_y_continuous(limits=c(0,25),breaks=seq(0,25,5)) + ggtitle("Figure 10: Participation rate per day in gardening and pet care, by gender, % (2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ2",filters=list(unit="Participation time",age="total",acl00="^tv|^radio",sex="total",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))][geo!="Turkey"] dt<-dt[,c("acl00","geo","values")] dt dt_sep<-data.table::data.table(acl00=c("Radio and music","Radio and music"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Radio and music",acl00)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) acl_ord<-sort(unique(dt$acl00),decreasing=TRUE) dt$acl00<-factor(dt$acl00,levels=acl_ord) fig11_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=acl00)) + theme_minimal() + geom_bar(position="dodge",stat="identity",width=0.7)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/96)) + scale_fill_manual(values = fig11_colors)+ ggtitle("Figure 11a: Participation time per day in the most common secondary activities watching TV and listening to radio, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ2",filters=list(unit="Participation time",age="total",acl00="^social|^visit",sex="total",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))][geo!="Turkey"] dt<-dt[,c("acl00","geo","values")] dt dt_sep<-data.table::data.table(acl00=c("Visiting and feasts","Visiting and feasts"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Visiting and feasts",acl00)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) fig11_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=acl00)) + theme_minimal() + geom_bar(position="dodge",stat="identity",width=0.7)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/96)) + scale_fill_manual(values = fig11_colors)+ ggtitle("Figure 11b: Participation time per day in the most common secondary activities socialising with family visiting and feasts (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ2",filters=list(unit="Participation time",age="total",acl00="^child",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))][geo!="Turkey"] dt<-dt[,c("sex","geo","values")] dt dt_sep<-data.table::data.table(sex=c("Males","Males"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Females",sex)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) sex_ord<-sort(unique(dt$sex),decreasing=TRUE) dt$sex<-factor(dt$sex,levels=sex_ord) fig11_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=sex)) + theme_minimal() + geom_bar(position="dodge",stat="identity",width=0.7)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/96)) + scale_fill_manual(values = fig11_colors)+ ggtitle("Figure 11c: Participation time per day in childcare as secondary activity, by gender, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00educ2",filters=list(unit="Participation time",age="total",acl00="^house",sex="male",isced97="^all"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))][geo!="Turkey"] dt<-dt[,c("sex","geo","values")] dt dt_sep<-data.table::data.table(sex=c("Males","Males"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Females",sex)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia') dt$geo<-factor(dt$geo,levels=geo_ord) sex_ord<-sort(unique(dt$sex),decreasing=TRUE) dt$sex<-factor(dt$sex,levels=sex_ord) fig11_colors<-c("#FAA519","#286EB4") #"#FCC975","#71A8DF", options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt, aes(x=geo, y=values,fill=sex)) + theme_minimal() + geom_bar(position="dodge",stat="identity",width=0.7)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/96)) + scale_fill_manual(values = fig11_colors)+ ggtitle("Figure 11d: Participation time per day in household and family care as secondary activity, by gender, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank()) dt<-get_eurostat_data("tus_00npaywork",filters=list(unit="Participation time",age="total",acl00="main",sex="male"),date_filter=eval(yr),label=T,ignore.case=T,exact_match=F,perl=T,stringsAsFactors=F,force_local_filter=T) dt dt$geo<-gsub(" \\(.*\\)","",dt$geo) if (is.factor(dt$values)|is.character(dt$values)) dt<-dt[,values:=chron::times(paste0(values,":00"))] dt<-dt[,c("sex","geo","values")] dt casted<-dcast(dt,geo~sex,value.var="values") casted[,gap:=Females-Males] dt<-melt(casted,measure.vars=c("Females","Males","gap"),variable.name="sex",value.name="values") dt[,sex:=gsub("gap","Gender gap",sex)] dt dt_sep<-data.table::data.table(sex=c("Males","Males"),geo=c(" "," "),values=c(chron::times(NA),chron::times(NA))) dt<-rbind(dt,dt_sep) geo_ord<-dt[(geo %in% eu_ctry_names)&grepl("Females",sex)] geo_ord<-geo_ord[order(values)]$geo geo_ord<-c(geo_ord,' ','Norway',' ','Serbia','Turkey') dt$geo<-factor(dt$geo,levels=geo_ord) sex_ord<-c('Males','Females',"Gender gap") dt$sex<-factor(dt$sex,levels=sex_ord) fig12_colors<-c("#FAA519","#286EB4","black") #F06423 options(repr.plot.width=9, repr.plot.height=6,repr.plot.res=300) ggplot(dt,aes(x=geo,y=values)) + theme_minimal() + geom_bar(data=dt[sex!="Gender gap"], aes(fill=sex),position="dodge",stat="identity",width=0.6)+ geom_point(data=dt[grepl("Gender gap",sex)],aes(shape=sex),colour="#F06423",fill="black",size=3)+ scale_y_chron(format="%H:%M",breaks=seq(0,1,1/24)) + scale_fill_manual(values = fig12_colors)+ scale_shape_manual(values=c("Males"=NA,"Females"=NA,"Gender gap"=21))+ ggtitle("Figure 12: Participation time per day in unpaid work (main activity), by gender, (hh mm; 2008 to 2015)") + ylab("")+ xlab("")+ theme(legend.title = element_blank(), legend.position= "bottom", axis.text.x = element_text(angle = 90, hjust = 1), panel.grid.major.x = element_blank(), panel.grid.minor.y = element_blank())