etc5523-2020 / exercise2C

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

Help! Unable to generate a line graph using ggplot #44

Open Siddhant-96 opened 4 years ago

Siddhant-96 commented 4 years ago

Hi, I am trying to generate a line graph using the following dataset and I've attached the results as well. I'm encountering the following problems : I am only getting a scatter plot and not a line in spite of using geom_line(). The x-axis is very unclear as the dates are overlapping!

     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

ggplot(count_date1, aes(Date,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?

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

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

Session info ``` r sessionInfo() #> R version 4.0.2 (2020-06-22) #> Platform: i386-w64-mingw32/i386 (32-bit) #> Running under: Windows 10 x64 (build 18363) #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=English_India.1252 LC_CTYPE=English_India.1252 #> [3] LC_MONETARY=English_India.1252 LC_NUMERIC=C #> [5] LC_TIME=English_India.1252 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.1 purrr_0.3.4 #> [5] readr_1.3.1 tidyr_1.1.1 tibble_3.0.3 ggplot2_3.3.2 #> [9] tidyverse_1.3.0 #> #> loaded via a namespace (and not attached): #> [1] tidyselect_1.1.0 xfun_0.16 haven_2.3.1 colorspace_1.4-1 #> [5] vctrs_0.3.2 generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 #> [9] blob_1.2.1 rlang_0.4.7 pillar_1.4.6 glue_1.4.1 #> [13] withr_2.2.0 DBI_1.1.0 dbplyr_1.4.4 modelr_0.1.8 #> [17] readxl_1.3.1 lifecycle_0.2.0 munsell_0.5.0 gtable_0.3.0 #> [21] cellranger_1.1.0 rvest_0.3.6 evaluate_0.14 labeling_0.3 #> [25] knitr_1.29 curl_4.3 fansi_0.4.1 highr_0.8 #> [29] broom_0.7.0 Rcpp_1.0.5 scales_1.1.1 backports_1.1.7 #> [33] jsonlite_1.7.0 mime_0.9 farver_2.0.3 fs_1.5.0 #> [37] hms_0.5.3 digest_0.6.25 stringi_1.4.6 grid_4.0.2 #> [41] cli_2.0.2 tools_4.0.2 magrittr_1.5 crayon_1.3.4 #> [45] pkgconfig_2.0.3 ellipsis_0.3.1 xml2_1.3.2 reprex_0.3.0 #> [49] lubridate_1.7.9 assertthat_0.2.1 rmarkdown_2.3 httr_1.4.2 #> [53] R6_2.4.1 compiler_4.0.2 ```