I want to show the traffic flow of city a in some days in December 2018 with figure. I take the date as the x-axis and the traffic flow as the y-axis, so that you can clearly see the trend of the traffic flow. However, when I show the figure with ggplot2, the effect is not good. First, dates are not in chronological order, so the trend is completely inaccurate. Second, there are only a few points in the figure, and there is no line or pie chart to show it more intuitively. What should I do?
Below you can see the dataset I used, the code to generate the plot, the error messages, the R packages I am using and their versions and my hardware information.
Thank you for your help!
library(ggplot2)
Date <- c('7-12-2018', '24-12-2018', '15-12-2018', '4/12/2018', '13-12-2018', '12/12/2018', '25-12-2018', '8/12/2018', '7-12-2018', '06-12-2018')
car <- c(25,16,27,19,21,16,24,30,46,28)
count_date1 <- data.frame(Date,car)
ggplot(count_date1, aes(Date, car)) +
geom_point() +
xlab("Date") +
ylab("No. of Cars")
I want to show the traffic flow of city a in some days in December 2018 with figure. I take the date as the x-axis and the traffic flow as the y-axis, so that you can clearly see the trend of the traffic flow. However, when I show the figure with ggplot2, the effect is not good. First, dates are not in chronological order, so the trend is completely inaccurate. Second, there are only a few points in the figure, and there is no line or pie chart to show it more intuitively. What should I do?
Below you can see the dataset I used, the code to generate the plot, the error messages, the R packages I am using and their versions and my hardware information.
Thank you for your help!
Created on 2020-08-12 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 Chinese (Simplified)_China.936 #> ctype Chinese (Simplified)_China.936 #> tz Asia/Taipei #> date 2020-08-12 #> #> - Packages ------------------------------------------------------------------- #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.3) #> backports 1.1.7 2020-05-13 [2] CRAN (R 3.6.3) #> callr 3.4.3 2020-03-28 [2] CRAN (R 3.6.3) #> cli 2.0.2 2020-02-28 [2] CRAN (R 3.6.3) #> colorspace 1.4-1 2019-03-18 [2] CRAN (R 3.6.1) #> crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.3) #> curl 4.3 2019-12-02 [2] CRAN (R 3.6.3) #> desc 1.2.0 2018-05-01 [2] 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 [2] CRAN (R 3.6.3) #> dplyr 0.8.5 2020-03-07 [2] CRAN (R 3.6.3) #> ellipsis 0.3.1 2020-05-15 [2] CRAN (R 3.6.3) #> evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.3) #> fansi 0.4.1 2020-01-08 [2] CRAN (R 3.6.3) #> farver 2.0.3 2020-01-16 [2] CRAN (R 3.6.3) #> fs 1.4.1 2020-04-04 [2] CRAN (R 3.6.3) #> ggplot2 * 3.3.0 2020-03-05 [2] 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 [2] CRAN (R 3.6.3) #> highr 0.8 2019-03-20 [2] CRAN (R 3.6.3) #> htmltools 0.4.0 2019-10-04 [2] CRAN (R 3.6.3) #> httr 1.4.1 2019-08-05 [2] CRAN (R 3.6.3) #> knitr 1.28 2020-02-06 [2] CRAN (R 3.6.3) #> labeling 0.3 2014-08-23 [2] CRAN (R 3.6.0) #> lifecycle 0.2.0 2020-03-06 [2] CRAN (R 3.6.3) #> magrittr 1.5 2014-11-22 [2] CRAN (R 3.6.3) #> memoise 1.1.0 2017-04-21 [2] CRAN (R 3.6.3) #> mime 0.9 2020-02-04 [2] CRAN (R 3.6.2) #> munsell 0.5.0 2018-06-12 [2] CRAN (R 3.6.3) #> pillar 1.4.4 2020-05-05 [2] CRAN (R 3.6.3) #> pkgbuild 1.0.8 2020-05-07 [2] CRAN (R 3.6.3) #> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 3.6.3) #> pkgload 1.0.2 2018-10-29 [2] CRAN (R 3.6.3) #> prettyunits 1.1.1 2020-01-24 [2] CRAN (R 3.6.3) #> processx 3.4.2 2020-02-09 [2] CRAN (R 3.6.3) #> ps 1.3.3 2020-05-08 [2] CRAN (R 3.6.3) #> purrr 0.3.4 2020-04-17 [2] CRAN (R 3.6.3) #> R6 2.4.1 2019-11-12 [2] CRAN (R 3.6.3) #> Rcpp 1.0.4 2020-03-17 [2] CRAN (R 3.6.3) #> remotes 2.1.1 2020-02-15 [2] 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 [2] 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 [2] CRAN (R 3.6.2) #> stringr 1.4.0 2019-02-10 [2] CRAN (R 3.6.3) #> testthat 2.3.2 2020-03-02 [2] CRAN (R 3.6.3) #> tibble 3.0.1 2020-04-20 [2] CRAN (R 3.6.3) #> tidyselect 1.1.0 2020-05-11 [2] CRAN (R 3.6.3) #> usethis 1.6.1 2020-04-29 [2] CRAN (R 3.6.3) #> vctrs 0.3.0 2020-05-11 [2] CRAN (R 3.6.3) #> withr 2.2.0 2020-04-20 [2] CRAN (R 3.6.3) #> xfun 0.14 2020-05-20 [2] CRAN (R 3.6.3) #> xml2 1.3.2 2020-04-23 [2] CRAN (R 3.6.3) #> yaml 2.2.1 2020-02-01 [2] CRAN (R 3.6.2) #> #> [1] C:/Users/63168/Documents/R/win-library/3.6 #> [2] E:/R/R-3.6.3/library ```