etc5523-2020 / exercise2C

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

How to beautifully plot line graph using date and freq in R using ggplot? #2

Open kabugit opened 4 years ago

kabugit commented 4 years ago

I have a dataframe (below graph) that I need to plot using ggplot. I have tried the code (below dataframe) but it produces an unpalatable graph below. Is there a way to get a neater line graph instead, that can show dates in a non congested way?

image

     Date        freq

1 13-04-2015 24 2 13-05-2015 12 3 13-06-2015 32 4 14-04-2015 23 5 14-05-2015 15 6 14-06-2015 16 7 15-04-2015 12 8 15-05-2015 12 9 15-06-2015 34 10 16-04-2015 20 11 16-05-2015 16 12 16-06-2015 29 13 17-04-2015 21 14 17-05-2015 7 15 17-06-2015 32 16 18-04-2015 8 17 18-05-2015 14 18 18-06-2015 47 19 19-04-2015 9 20 19-05-2015 12 21 19-06-2015 29 22 20-04-2015 20 23 20-05-2015 15 24 20-06-2015 16 25 21-04-2015 12 26 21-05-2015 17 27 21-06-2015 12 28 22-04-2015 22 29 22-05-2015 14 30 22-06-2015 30 31 23-04-2015 23 32 23-05-2015 12 33 23-06-2015 190 34 24-04-2015 24 35 24-05-2015 7 36 24-06-2015 218 37 25-04-2015 16 38 25-05-2015 12 39 25-06-2015 98 40 26-04-2015 8 41 26-05-2015 27 42 26-06-2015 55 43 27-04-2015 25 44 27-05-2015 17 45 27-06-2015 39 46 28-04-2015 26 47 28-05-2015 26 48 28-06-2015 27 49 29-04-2015 22 50 29-05-2015 14 51 29-06-2015 51 52 30-04-2015 24 53 30-05-2015 9 54 30-06-2015 53 55 31-05-2015 10 56 4/1/2015 18 57 4/10/2015 21 58 4/11/2015 5 59 4/12/2015 15 60 4/2/2015 27 61 4/3/2015 15 62 4/4/2015 12 63 4/5/2015 6 64 4/6/2015 13 65 4/7/2015 25 66 4/8/2015 28 67 4/9/2015 21 68 5/1/2015 12 69 5/10/2015 7 70 5/11/2015 12 71 5/12/2015 7 72 5/2/2015 7 73 5/3/2015 5 74 5/4/2015 12 75 5/5/2015 14 76 5/6/2015 14 77 5/7/2015 15 78 5/8/2015 15 79 5/9/2015 11 80 6/1/2015 25 81 6/10/2015 25 82 6/11/2015 21 83 6/12/2015 43 84 6/2/2015 25 85 6/3/2015 25 86 6/4/2015 12 87 6/5/2015 29 88 6/6/2015 11 89 6/7/2015 9 90 6/8/2015 24 91 6/9/2015 23

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