Closed p-wegmueller closed 1 year ago
I dig a bit into the issue with a MWE:
df <- structure(list(id = c("total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "total", "total", "total",
"total", "total", "total", "total", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female", "female",
"female", "female", "female", "female", "female", "female"),
time = structure(c(1461, 1492, 1520, 1551, 1581, 1612, 1642,
1673, 1704, 1734, 1765, 1795, 1826, 1857, 1885, 1916, 1946,
1977, 2007, 2038, 2069, 2099, 2130, 2160, 2191, 2222, 2251,
2282, 2312, 2343, 2373, 2404, 2435, 2465, 2496, 2526, 2557,
2588, 2616, 2647, 2677, 2708, 2738, 2769, 2800, 2830, 2861,
2891, 2922, 2953, 2981, 3012, 3042, 3073, 3103, 3134, 3165,
3195, 3226, 3256, 3287, 3318, 3346, 3377, 3407, 3438, 3468,
3499, 3530, 3560, 3591, 3621, 1461, 1492, 1520, 1551, 1581,
1612, 1642, 1673, 1704, 1734, 1765, 1795, 1826, 1857, 1885,
1916, 1946, 1977, 2007, 2038, 2069, 2099, 2130, 2160, 2191,
2222, 2251, 2282, 2312, 2343, 2373, 2404, 2435, 2465, 2496,
2526, 2557, 2588, 2616, 2647, 2677, 2708, 2738, 2769, 2800,
2830, 2861, 2891, 2922, 2953, 2981, 3012, 3042, 3073, 3103,
3134, 3165, 3195, 3226, 3256, 3287, 3318, 3346, 3377, 3407,
3438, 3468, 3499, 3530, 3560, 3591, 3621), class = "Date"),
value = c(3035, 2552, 2704, 2554, 2014, 1655, 1721, 1524,
1596, 2074, 2199, 2512, 2933, 2889, 2938, 2497, 1870, 1726,
1607, 1545, 1396, 1787, 2076, 2837, 2787, 3891, 3179, 2011,
1636, 1580, 1489, 1300, 1356, 1653, 2013, 2823, 3102, 2294,
2385, 2444, 1748, 1554, 1498, 1361, 1346, 1564, 1640, 2293,
2815, 3137, 2679, 1969, 1870, 1633, 1529, 1366, 1357, 1570,
1535, 2491, 3084, 2605, 2573, 2143, 1693, 1504, 1461, 1354,
1333, 1492, 1781, 1915, 901, 689, 827, 677, 522, 406, 441,
393, 387, 582, 578, 666, 830, 752, 785, 664, 467, 438, 421,
412, 343, 440, 531, 771, 767, 1141, 896, 532, 447, 420, 376,
330, 357, 445, 546, 764, 862, 660, 663, 643, 502, 392, 411,
348, 387, 385, 411, 638, 796, 853, 737, 546, 530, 446, 431,
362, 387, 430, 425, 679, 821, 785, 727, 612, 478, 429, 405,
379, 393, 411, 487, 574)), row.names = c(NA, 144L), class = "data.frame")
cname <- list(id = "id", time = "time", value = "value")
# WORKS
df %>% ggplot2::ggplot(ggplot2::aes(x=time, y=value, color = id)) + ggplot2::geom_line()
# DOESNT WORK
df %>% ggplot2::ggplot(ggplot2::aes(x=!!cname$time, y=!!cname$value, color = cname$id)) + ggplot2::geom_line()
Something with the aestethics and the double exclamation seems not to work anymore.
library(tsbox)
packageVersion("tsbox")
#> [1] '0.4.1.9001'
AirPassengers |> ts_ggplot()
#> Loading required namespace: ggplot2
Created on 2023-09-14 with reprex v2.0.2
I believe something is still not working as it should:
ts_c(NEU = fdeaths, ALT = mdeaths) %>% ts_ggplot()
renders a strange graph, but it should look like
ts_c(NEU = fdeaths, ALT = mdeaths) %>% ts_plot()
As you've mentioned, I forgot the color mapping. Fixed now.
library(tsbox)
packageVersion("tsbox")
#> [1] '0.4.1.9002'
ts_c(mdeaths, fdeaths) |> ts_ggplot()
#> Loading required namespace: ggplot2
Thanks, @p-wegmueller!
Session Info
```r devtools::session_info() ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.2.0 (2022-04-22 ucrt) os Windows 10 x64 (build 19044) system x86_64, mingw32 ui RStudio language (EN) collate German_Switzerland.utf8 ctype German_Switzerland.utf8 tz Europe/Berlin date 2023-09-06 rstudio 2022.07.1+554 Spotted Wakerobin (desktop) pandoc 2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown) ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────── ! package * version date (UTC) lib source anytime 0.3.9 2020-08-27 [1] CRAN (R 4.2.2) cachem 1.0.6 2021-08-19 [1] CRAN (R 4.2.2) callr 3.7.3 2022-11-02 [1] CRAN (R 4.2.2) cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.3) colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.2) cowplot * 1.1.1 2020-12-30 [1] CRAN (R 4.2.2) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.2) curl 5.0.0 2023-01-12 [1] CRAN (R 4.2.2) data.table 1.14.8 2023-02-17 [1] CRAN (R 4.2.3) desc 1.4.2 2022-09-08 [1] CRAN (R 4.2.2) devtools 2.4.5 2022-10-11 [1] CRAN (R 4.2.2) digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.2) P dpkjdown * 0.3.1 2023-02-07 [?] Github (dpkj/dpkjdown@e6bf970) dplyr * 1.1.3 2023-09-03 [1] CRAN (R 4.2.3) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.2) evaluate 0.20 2023-01-17 [1] CRAN (R 4.2.2) extrafont 0.19 2023-01-18 [1] CRAN (R 4.2.2) extrafontdb 1.0 2012-06-11 [1] CRAN (R 4.2.0) fansi 1.0.4 2023-01-22 [1] CRAN (R 4.2.2) farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.2) fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.2) forecast 8.21.1 2023-08-31 [1] CRAN (R 4.2.3) fracdiff 1.5-2 2022-10-31 [1] CRAN (R 4.2.2) fs 1.6.1 2023-02-06 [1] CRAN (R 4.2.0) generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.2) ggplot2 3.4.3 2023-08-14 [1] CRAN (R 4.2.3) glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.2) gtable 0.3.4 2023-08-21 [1] CRAN (R 4.2.3) htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.2.2) htmlwidgets 1.6.1 2023-01-07 [1] CRAN (R 4.2.2) httpuv 1.6.8 2023-01-12 [1] CRAN (R 4.2.2) httr 1.4.5 2023-02-24 [1] CRAN (R 4.2.3) kableExtra 1.3.4 2021-02-20 [1] CRAN (R 4.2.2) knitr 1.42 2023-01-25 [1] CRAN (R 4.2.2) later 1.3.0 2021-08-18 [1] CRAN (R 4.2.2) lattice 0.20-45 2021-09-22 [1] CRAN (R 4.2.0) lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.2) lmtest 0.9-40 2022-03-21 [1] CRAN (R 4.2.2) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.2) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.2.2) mime 0.12 2021-09-28 [1] CRAN (R 4.2.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.2.2) munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.2) nlme 3.1-162 2023-01-31 [1] CRAN (R 4.2.0) nnet 7.3-18 2022-09-28 [1] CRAN (R 4.2.2) pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.3) pkgbuild 1.4.0 2022-11-27 [1] CRAN (R 4.2.2) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.2) pkgload 1.3.2 2022-11-16 [1] CRAN (R 4.2.2) plyr 1.8.8 2022-11-11 [1] CRAN (R 4.2.2) prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.2.2) processx 3.8.0 2022-10-26 [1] CRAN (R 4.2.2) profvis 0.3.7 2020-11-02 [1] CRAN (R 4.2.2) promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.2.2) ps 1.7.2 2022-10-26 [1] CRAN (R 4.2.2) purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.2) quadprog 1.5-8 2019-11-20 [1] CRAN (R 4.2.0) quantmod 0.4.25 2023-08-22 [1] CRAN (R 4.2.3) R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.2) Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.2.3) remotes 2.4.2 2021-11-30 [1] CRAN (R 4.2.2) reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.2.2) rlang * 1.1.1 2023-04-28 [1] CRAN (R 4.2.3) rmarkdown 2.20 2023-01-19 [1] CRAN (R 4.2.2) rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.2.2) rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.2) Rttf2pt1 1.3.12 2023-01-22 [1] CRAN (R 4.2.2) rvest 1.0.3 2022-08-19 [1] CRAN (R 4.2.2) scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.2) seasonal * 1.9.0 2022-04-18 [1] CRAN (R 4.2.2) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.2) shiny 1.7.4 2022-12-15 [1] CRAN (R 4.2.2) stringi 1.7.12 2023-01-11 [1] CRAN (R 4.2.2) stringr 1.5.0 2022-12-02 [1] CRAN (R 4.2.2) svglite 2.1.1 2023-01-10 [1] CRAN (R 4.2.2) systemfonts 1.0.4 2022-02-11 [1] CRAN (R 4.2.2) tempdisagg * 1.1.1 2023-08-08 [1] CRAN (R 4.2.3) tibble 3.2.1 2023-03-20 [1] CRAN (R 4.2.3) tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.2) timeDate 4022.108 2023-01-07 [1] CRAN (R 4.2.2) tsbox * 0.4.1 2023-05-08 [1] CRAN (R 4.2.3) tseries 0.10-54 2023-05-02 [1] CRAN (R 4.2.3) tstools * 1.1.8 2023-09-05 [1] Github (dpkj/tstools@dd4fb88) TTR 0.24.3 2021-12-12 [1] CRAN (R 4.2.3) urca 1.3-3 2022-08-29 [1] CRAN (R 4.2.2) urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.2.2) usethis 2.1.6 2022-05-25 [1] CRAN (R 4.2.2) utf8 1.2.3 2023-01-31 [1] CRAN (R 4.2.0) vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.2.3) viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.2.3) vts 0.17.2 2023-02-07 [1] local webshot 0.5.4 2022-09-26 [1] CRAN (R 4.2.2) withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.2) x13binary 1.1.57-3 2022-02-07 [1] CRAN (R 4.2.0) xfun 0.40 2023-08-09 [1] CRAN (R 4.2.3) xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.2) xtable 1.8-4 2019-04-21 [1] CRAN (R 4.2.2) xts 0.13.1 2023-04-16 [1] CRAN (R 4.2.3) zoo 1.8-12 2023-04-13 [1] CRAN (R 4.2.3) p <- ts_ggplot(total = ldeaths, female = fdeaths, male = mdeaths) p ```