etc5523-2020 / exercise2C

For students to submit their reproducible example in the issue
0 stars 0 forks source link

Make line graph that overlap the geom_point #20

Open whysptra opened 4 years ago

whysptra commented 4 years ago

I want to create a graph that shows the number of complaints by customers on a certain date. I have the Date and freq variables stored in count_date1. I want to show a line that overlaps each point, however from the code that I'm working with, only dots appear. Here's my code, hope that anyone can help me.

library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
library(ggplot2)
library(tidyverse)
count_date1 <- tibble(Date = c(
               "13-04-2015",
               "13-05-2015",
               "13-06-2015",
               "14-04-2015",
               "14-05-2015",
               "14-06-2015",
               "15-04-2015",
               "15-05-2015",
               "15-06-2015",
               "16-04-2015",
               "16-05-2015",
               "16-06-2015",
               "17-04-2015"),
               freq = c(24,12,32,23,15,16,12,12,34,20,16,29,21)

)

count_date1$Date <- dmy(count_date1$Date)

ggplot(count_date1, aes(x=Date,y=freq)) +
  geom_point() +
 geom_line(aes(group=Date)) +
  xlab("Date") +
  ylab("No. of Complaints")
#> geom_path: Each group consists of only one observation. Do you need to adjust
#> the group aesthetic?

Created on 2020-08-13 by the reprex package (v0.3.0)