Skip to Content

Create line graph with ggplot2, using time periods as x-variable

I am very new to R, and so this question is extremely elementary, but I can't solve it myself. I would very much appreciate your help.

This is a sort of dataframe I want to use:

     Period                           Value   Cut.off
1   January 1998 - August 2002      8.798129    1.64
2   September 2002 - Jun 2006       4.267268    1.64
3   Jul 2006 - Dec 2009             7.280275    1.64

This the code I am using:

require(ggplot2)
bq <- ggplot(data=glomor, aes(x=as.character(Period),y=Value))+geom_point()+ylim(0,10)
 
bq <- bq + scale_x_discrete(limits=c("January 1998 - August 2002","September 2002 - Jun 2006","Jul 2006 - Dec 2009"))
 
bq + geom_line()

I receive the following error message:

geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?

How do I need to change the code, so that the points will be connected by a line?