Open andkov opened 5 years ago
NOTE: requires the viridis package for the viridis colours.
g2 <- ds1 %>%
dplyr::filter(area == "British Columbia" ) %>%
dplyr::filter(age_group == "20-34" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
geom_point()+
geom_line( aes(group = sex) )+
theme_classic(base_size = 12) +
scale_color_viridis_d(end = 0.5) +
labs( title = "Crude prevalence of MH service utilization\nin BC among 20-34 year olds")
g2
quick_save <- function(g,name){
ggplot2::ggsave(
filename = paste0(name,".png"),
plot = g,
device = png,
path = where_to_store_graphs,
width = 1000,
height = 400,
res = 150,
limitsize = FALSE
)
}
`g1 <- ds1 %>%
dplyr::filter(area == "British Columbia" ) %>%
dplyr::filter(age_group == "20-34" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
geom_point()+
geom_line( aes(group = sex) )+
theme_minimal()+
labs( title = "Crude prevalence of MH service utilization in BC among 20-34 year olds")
g1`
g2 <- ds1 %>%
dplyr::filter(area %in% c("Manitoba","Saskatchewan","Alberta","British Columbia") )%>%
dplyr::filter(age_group == "20-34" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
facet_wrap(~area) +
geom_point()+
geom_line( aes(group = sex) )+
theme_minimal()+
labs( title = "Crude prevalence of MH service utilization in Western Canada among 20-34 year olds")
g2
Manitoba for 80+ year olds.
g1 <- ds1 %>%
dplyr::filter(area == "Manitoba" ) %>%
dplyr::filter(age_group == "80+" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
geom_point()+
geom_line( aes(group = sex) )+
theme_minimal()+
labs( title = "Crude prevalence of MH service utilization in MB among 80+ year olds")
g1
g1 %>% quick_save(name = "graph-mn") # will produce error, debug
g1 <- ds1 %>%
dplyr::filter(area == "British Columbia" ) %>%
dplyr::filter(age_group == "20-34" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
geom_point(shape = 21, size = 3)+
geom_smooth(method = "lm", se = FALSE, size = .2, )+
geom_line( aes(group = sex) )+
theme_bw()+
labs( title = "Crude prevalence of MH service utilization in BC among 20-34 year olds")
g1
g1 <- ds1 %>%
dplyr::filter(area == "British Columbia" ) %>%
dplyr::filter(age_group == "20-34" ) %>%
dplyr::filter(sex %in% c("Males","Females") ) %>%
ggplot(aes(
x = year
,y = rate
,color = sex
))+
geom_point(shape = 21, size = 3)+
geom_smooth(method = "lm", se = FALSE, size = .2 )+
geom_line( aes(group = sex) )+
theme_bw()+
labs( title = "Crude prevalence of MH service utilization \n\n in BC among 20-34 year olds")
g1