Using my simple data frame
> str(dta)
Classes 'tbl_df', 'tbl' and 'data.frame': 54 obs. of 4 variables:
$ year : num 2016 2016 2017 2017 2018 ...
$ severef: num 0.112 0.465 0.11 0.457 0.114 ...
$ package: Factor w/ 3 levels "Baseline","HSS",..: 1 1 1 1 1 1 1 1 1 1 ...
$ run_nb : int 1 2 1 2 1 2 1 2 1 2 ...
When running
library(ggplot2)
ggplot(dta, aes(x = year, y = severef, color = package, group = run_nb)) +
geom_line()
I am expecting that several distinct lines will be drawn because of the aes(..., group = run_nb)
as per Overlapping Lines in ggplot2
Instead, the output is jammed. I have tried several transformations of variable types but to no avail. What am I doing wrong?
dta <- structure(list(year = c(2016, 2016, 2017, 2017, 2018, 2018, 2019,
2019, 2020, 2020, 2021, 2021, 2022, 2022, 2023, 2023, 2024, 2024,
2016, 2016, 2017, 2017, 2018, 2018, 2019, 2019, 2020, 2020, 2021,
2021, 2022, 2022, 2023, 2023, 2024, 2024, 2016, 2016, 2017, 2017,
2018, 2018, 2019, 2019, 2020, 2020, 2021, 2021, 2022, 2022, 2023,
2023, 2024, 2024), severef = c(0.111823385630219, 0.465018440108279,
0.109918488465996, 0.457096910073382, 0.11417253918809, 0.474787413895822,
0.124623038552219, 0.518245898767047, 0.138076553592572, 0.574192448254701,
0.133435431355833, 0.554892304454577, 0.139052739728505, 0.57825192607885,
0.150916617717648, 0.627587957223443, 0.144179084276974, 0.599569870728368,
0.112252179138183, 0.466801581327609, 0.109674033567054, 0.456080342428412,
0.111055456891102, 0.461825002328107, 0.120224868167075, 0.499956072177523,
0.125299916066184, 0.521060699301965, 0.0855819441772642, 0.355893196744622,
0.0495125747278424, 0.205898436502569, 0.030746318019459, 0.12785880845856,
0.0284200221496644, 0.118184888549004, 0.111823385630219, 0.465018440108279,
0.109918488465996, 0.457096910073382, 0.11417253918809, 0.474787413895822,
0.113843419896702, 0.473418768700291, 0.097003856181354, 0.403391308818959,
0.0628228996117884, 0.261249528583923, 0.0389240209844475, 0.161865851395205,
0.0297564629438263, 0.123742488239764, 0.0276489857179591, 0.114978527404441
), package = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Baseline",
"HSS", "VMW+ HSS"), class = "factor"), run_nb = c(1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-54L))