etc5523-2020 / exercise2C

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

How to reorder the dates on X-axis and slove the overcrowding on the X-axis #13

Open Sen101 opened 4 years ago

Sen101 commented 4 years ago

Hi, I tried to draw a plot to show the relationship between the freq and the dates. But there were some problems in this plot. Firstly, the dates on X-axis were not chronological. Secondly, the dates on X-axis are too crowded. Finally, the line polt was not drawn. Here is my code, thank you !

library(ggplot2)
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',  '6/11/2015', '6/12/2015', '6/2/2015', '6/3/2015', '6/4/2015', '6/5/2015', '6/6/2015', '6/7/2015', '6/8/2015', '6/9/2015')

freq <- c(24, 12, 32, 23, 15, 16, 12, 12, 34, 20, 21, 43, 25, 25, 12, 29, 11, 9, 24, 23)

count_date1 <- data.frame(Date,freq)

ggplot(count_date1, aes(Date,freq)) + 
    geom_point() + 
    geom_line(aes(group=Date)) +
    xlab("Date") + 
    ylab("No. of Complaints")

2020-08-13 (3)