Hi guys i keep struggling with ordering my months in a calender year on my x axis....Can someone support

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()

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(...)

Thank you.
It worked perfectly

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.