Brayo
February 5, 2025, 9:11am
1
Line Graph for BCG Coverage
Step 1 Group the BCG Coverage by Month
mywak<-mywak %>%
group_by(Month) %>%
summarise(mean(BCG, na.rm = TRUE))
view(mywak)
Step 2 Standardise the order of Months
mywak%>%
mutate(Month=factor(Month,levels=c("Jan","Feb","Mar","Apr","May","Jun"))) %>%
factor(Month= levels(month.abb))
##Step 2 Draw a line graph with points well outlined
mywak%>%
ggplot(aes(x=Month,y= mean(BCG, na.rm = TRUE)
, group=1))+
geom_line(color="yellow", size=1)+
geom_point(color="red", size=3)+
labs(title = "Monthly BCG Coverage", ylab ="Coverage(%)", xlab="Month")+
theme_bw()
margusl
February 5, 2025, 11:32am
2
Your changes to mywak
are not stored anywhere and you are calling ggplot()
with mywak
from Step 1
You could write your standardisation step results back to mywak
like in your 1st step (skip final factor()
call) :
mywak <- mywak %>% mutate(...)
Or just pipe it right into ggplot
:
mywak %>%
mutate(Month = factor(Month, levels = c("Jan","Feb","Mar","Apr","May","Jun"))) %>%
ggplot(...)
Brayo
February 5, 2025, 4:32pm
3
Thank you.
It worked perfectly
system
Closed
February 12, 2025, 4:33pm
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.