How to write code to summarise means from two character variables for comparative graph

Viewed 27

I am just getting into using R and working on a data set that looks at the median age of women getting married in each state in 2006-2010 and 2015-2019.

I have the below plot using the following code:

ggplot(data=df, aes(x=TimeFrame, y=Median.Age, group=1)) +
  geom_line() + 
  geom_point()

enter image description here

However, instead of having an individual dot for each state, I would like to summarise the mean age for marriage in 2006-2010 and 2015-2019 among all states in order to have two comparative means and compare them like that.

How can I go about this?

0 Answers
Related