I try to create a line plot using ggplot for my two variables (date and freq). However, I just got scattered points in my plot, instead of line (although I already used geom_line). Below I attach reproducible error. Any help would be appreciated.
library(ggplot2)
date <- c("30-06-2015", "31-05-2015", "4/1/2015", "4/10/2015")
freq <- c(10,5,4,3)
case <- data.frame(date, freq)
ggplot(case, 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?
I try to create a line plot using ggplot for my two variables (date and freq). However, I just got scattered points in my plot, instead of line (although I already used geom_line). Below I attach reproducible error. Any help would be appreciated.
Created on 2020-08-13 by the reprex package (v0.3.0)
Session info
``` r sessionInfo() #> R version 4.0.2 (2020-06-22) #> Platform: x86_64-w64-mingw32/x64 (64-bit) #> Running under: Windows 10 x64 (build 18363) #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=English_United States.1252 #> [2] LC_CTYPE=English_United States.1252 #> [3] LC_MONETARY=English_United States.1252 #> [4] LC_NUMERIC=C #> [5] LC_TIME=English_United States.1252 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] ggplot2_3.3.2 #> #> loaded via a namespace (and not attached): #> [1] xml2_1.3.2 knitr_1.29 magrittr_1.5 tidyselect_1.1.0 #> [5] munsell_0.5.0 colorspace_1.4-1 R6_2.4.1 rlang_0.4.7 #> [9] httr_1.4.2 dplyr_1.0.1 stringr_1.4.0 highr_0.8 #> [13] tools_4.0.2 grid_4.0.2 gtable_0.3.0 xfun_0.16 #> [17] withr_2.2.0 htmltools_0.5.0 ellipsis_0.3.1 yaml_2.2.1 #> [21] digest_0.6.25 tibble_3.0.3 lifecycle_0.2.0 crayon_1.3.4 #> [25] farver_2.0.3 purrr_0.3.4 vctrs_0.3.2 curl_4.3 #> [29] mime_0.9 glue_1.4.1 evaluate_0.14 rmarkdown_2.3 #> [33] labeling_0.3 stringi_1.4.6 compiler_4.0.2 pillar_1.4.6 #> [37] generics_0.0.2 scales_1.1.1 pkgconfig_2.0.3 ```