Open j-effendy opened 4 years ago
I am having difficulties in creating a time series plot from a data frame.
Below is an example of a data frame that closely resemble what I am working with:
date <- c("13-04-2015", "13-04-2015", "14-04-2015", "17/04/2015", "18/04/2015") frequency <- c(24, 12, 32, 23, 20) example <- data.frame(date,frequency)
I used the following codes to create a time series plot with ggplot2.
library(ggplot2) library(tidyverse) example %>% ggplot(aes(x = date, y = frequency)) + geom_line() + xlab("Date") + ylab("Frequency")
However, I got a funny looking graph:
Created on 2020-08-13 by the reprex package (v0.3.0)
Thanks for your help. Below is the information of my R session:
I am having difficulties in creating a time series plot from a data frame.
Below is an example of a data frame that closely resemble what I am working with:
I used the following codes to create a time series plot with ggplot2.
However, I got a funny looking graph:
Created on 2020-08-13 by the reprex package (v0.3.0)
Thanks for your help. Below is the information of my R session:
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 18362) #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 #> [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C #> [5] LC_TIME=English_Australia.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 tidyverse_1.3.0 #> [9] ggplot2_3.3.2 #> #> 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 backports_1.1.7 scales_1.1.1 #> [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 ```