Hi,
I am trying to create a scatter plot with the following data-frame, with Date as the x-axis and freq as the y-axis. However, I was facing some issues when generating the plot. The dates are not in chronological order and they are overlapping each other, which cannot be read easily. Also, I put “geom_line()” in the code but there is no line being generated.
Below is the dataset, the code, the error messages, and the R packages that I am using.
Can anyone please help me solve this issue? Thanks!
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', '16-05-2015', '4/1/2015', '4/10/2015', '4/11/2015', '4/12/2015', '4/2/2015', '4/3/2015', '4/4/2015', '4/5/2015', '4/6/2015', '4/7/2015', '4/8/2015')
freq <- c(24, 12, 32, 23, 15, 16, 12, 12, 34, 20, 16, 18, 21, 5, 15, 27, 15, 12, 6, 13, 25, 28)
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")
#> geom_path: Each group consists of only one observation. Do you need to adjust
#> the group aesthetic?
Hi, I am trying to create a scatter plot with the following data-frame, with Date as the x-axis and freq as the y-axis. However, I was facing some issues when generating the plot. The dates are not in chronological order and they are overlapping each other, which cannot be read easily. Also, I put “geom_line()” in the code but there is no line being generated.
Below is the dataset, the code, the error messages, and the R packages that I am using.
Can anyone please help me solve this issue? Thanks!
Created on 2020-08-13 by the reprex package (v0.3.0)
Session info
``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 3.6.3 (2020-02-29) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_Indonesia.1252 #> ctype English_Indonesia.1252 #> tz Australia/Sydney #> date 2020-08-13 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.3) #> backports 1.1.7 2020-05-13 [1] CRAN (R 3.6.3) #> callr 3.4.3 2020-03-28 [1] CRAN (R 3.6.3) #> cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.3) #> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.3) #> curl 4.3 2019-12-02 [1] CRAN (R 3.6.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.3) #> devtools 2.3.0 2020-04-10 [1] CRAN (R 3.6.3) #> digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.3) #> dplyr 0.8.5 2020-03-07 [1] CRAN (R 3.6.3) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.3) #> farver 2.0.3 2020-01-16 [1] CRAN (R 3.6.3) #> fs 1.4.0 2020-03-31 [1] CRAN (R 3.6.3) #> ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 3.6.3) #> glue 1.4.1 2020-05-13 [1] CRAN (R 3.6.3) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.3) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.3) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.3) #> httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.3) #> knitr 1.28 2020-02-06 [1] CRAN (R 3.6.3) #> labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.3) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.3) #> mime 0.9 2020-02-04 [1] CRAN (R 3.6.2) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.3) #> pillar 1.4.4 2020-05-05 [1] CRAN (R 3.6.3) #> pkgbuild 1.0.8 2020-05-07 [1] CRAN (R 3.6.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.3) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 3.6.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.3) #> processx 3.4.2 2020-02-09 [1] CRAN (R 3.6.3) #> ps 1.3.3 2020-05-08 [1] CRAN (R 3.6.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 3.6.3) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.3) #> Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.3) #> remotes 2.1.1 2020-02-15 [1] CRAN (R 3.6.3) #> rlang 0.4.6 2020-05-02 [1] CRAN (R 3.6.3) #> rmarkdown 2.3 2020-06-18 [1] CRAN (R 3.6.3) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.3) #> scales 1.1.1 2020-05-11 [1] CRAN (R 3.6.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.3) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.3) #> testthat 2.3.2 2020-03-02 [1] CRAN (R 3.6.3) #> tibble 3.0.1 2020-04-20 [1] CRAN (R 3.6.3) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 3.6.3) #> usethis 1.6.1 2020-04-29 [1] CRAN (R 3.6.3) #> vctrs 0.3.1 2020-06-05 [1] CRAN (R 3.6.3) #> withr 2.2.0 2020-04-20 [1] CRAN (R 3.6.3) #> xfun 0.14 2020-05-20 [1] CRAN (R 3.6.3) #> xml2 1.3.2 2020-04-23 [1] CRAN (R 3.6.3) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.2) #> #> [1] C:/Users/hellen/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.3/library ```