I am trying to create a line graph with multiple lines and points. I am struggling with 2 problems.
- I can get the points to appear in a graph, but when I add the geom_line() function , I am told my x axis object, match_date, is not found.
- Sometimes when I plot the graph, it does not pick up my date format correctly.
Columns of my dataset include match_date, team, and Shots.
Thank you for taking your time to help me.
tourn_stats <- data.frame(match_date = c(2019-07-06, 2019-06-07, 2019-06-19, 2019-06-14, 2019-06-23, 2019-06-27, 2019-07-02, 2019-06-23, 2019-06-07, 2019-06-12, 2019-06-28, 2019-06-17),
team = c("England", "England", "England", "England", "England", "England", "England", "France", "France", "France", "France", "France"),
Shots = c(10, 16, 17, 17, 7, 16, 7, 14, 22, 19, 19, 19))
ggplot(tourn_stats)+geom_point(size = 3, mapping=aes(x=match_date, y=Shots, color = team))+
xlab("Match Date")+
ylab("Number of Shots")+
geom_line(x = match_date, y = Shots)
Console Output:
ggplot(tourn_stats)+geom_point(size = 3, mapping=aes(x=match_date, y=Shots, color = team))+
- xlab("Match Date")+
- ylab("Number of Shots")+
- geom_point(x = match_date, y = Shots)
Error: object 'match_date' not found