@dromano thank you for making me aware of the pivot_longer() and pivot_wider() functions. i didnt know them and wasnt able to work with them (yet) but the description sounds very useful, especially with my data. i didnt use the pivot_longer() or pivot_wider() functions but in the end i got the format you asked me to have
tibble::tribble(
~schaetzung, ~unterer, ~oberer, ~Team, ~Datum, ~schaetz_type,
-1.20600722, -1.27406046, -1.13795403, "BE", "2019-09-04", "m",
-0.34178830, -0.49025695, -0.19332039, "SG", "2019-09-04", "m",
-0.77783117, -0.92155665, -0.63410838, "HM", "2019-09-04", "m",
-0.87023609, -0.95052642, -0.78996492, "LS", "2019-09-04", "m",
0.82741911, 0.71214397, 0.94205678, "SS", "2019-09-04", "m",
1.01777813, 0.91384768, 1.12461777, "PK", "2019-09-04", "m",
1.35778070, 1.20020542, 1.43455935, "RK", "2019-09-04", "m",
-0.89140967, -0.89352401, -0.79346693, "BE", "2019-09-04", "g",
-0.38676828, -0.55602560, -0.21751113, "SG", "2019-09-04", "g",
-0.50074202, -0.68063002, -0.32085244, "HM", "2019-09-04", "g",
-1.33333247, -1.40421368, -1.26241880, "LS", "2019-09-04", "g",
0.92697903, 0.81628041, 1.03717525, "SS", "2019-09-04", "g",
1.42290811, 1.34166203, 1.50219959, "PK", "2019-09-04", "g",
0.76853563, 0.68806555, 0.88419067, "RK", "2019-09-04", "g",
0.50713972, 0.58928908, 0.75534955, "BE", "2019-09-06", "m",
-0.95816018, -1.20883898, -0.70749798, "SG", "2019-09-06", "m",
-1.20572109, -1.37890104, -1.03340317, "HM", "2019-09-06", "m",
0.31418804, -0.00164114, 0.62999249, "LS", "2019-09-06", "m",
-0.35742292, -0.62883711, -0.11355746, "SS", "2019-09-06", "m",
1.87457744, 1.82436404, 2.06671846, "PK", "2019-09-06", "m",
-0.15417069, -0.58044760, 0.27210654, "RK", "2019-09-06", "m",
0.20285233, 0.00058871, 0.40511577, "BE", "2019-09-06", "g",
-1.37138008, -1.64445563, -1.09827060, "SG", "2019-09-06", "g",
-0.78744117, -0.93569569, -0.63888539, "HM", "2019-09-06", "g",
0.36839513, 0.10252459, 0.63166502, "LS", "2019-09-06", "g",
-0.32984756, -0.52593982, -0.13643571, "SS", "2019-09-06", "g",
1.91653954, 1.73966018, 2.12911299, "PK", "2019-09-06", "g",
0.09466097, -0.73383450, 0.46270508, "RK", "2019-09-06", "g",
0.91490866, 0.72448529, 1.03736747, "BE", "2019-09-07", "m")
#> # A tibble: 29 x 6
#> schaetzung unterer oberer Team Datum schaetz_type
#> <dbl> <dbl> <dbl> <chr> <chr> <chr>
#> 1 -1.21 -1.27 -1.14 BE 2019-09-04 m
#> 2 -0.342 -0.490 -0.193 SG 2019-09-04 m
#> 3 -0.778 -0.922 -0.634 HM 2019-09-04 m
#> 4 -0.870 -0.951 -0.790 LS 2019-09-04 m
#> 5 0.827 0.712 0.942 SS 2019-09-04 m
#> 6 1.02 0.914 1.12 PK 2019-09-04 m
#> 7 1.36 1.20 1.43 RK 2019-09-04 m
#> 8 -0.891 -0.894 -0.793 BE 2019-09-04 g
#> 9 -0.387 -0.556 -0.218 SG 2019-09-04 g
#> 10 -0.501 -0.681 -0.321 HM 2019-09-04 g
#> # ... with 19 more rows
this code
wf.team <- ggplot(fish_team, aes(x=Datum, y=schätzung, group=interaction(Team, schaetz_type), color=schaetz_type))+
geom_errorbar(aes(ymin=unterer, ymax=oberer), width=.1,
position=position_dodge(0.05)) +
geom_line(aes(x=Datum, y= schätzung)) +
geom_point(aes(shape=Team))+
labs(title="Plot123",x="Date", y = "Position")+
theme(axis.text.x = element_text(angle = 50, size = 10, vjust = 0.5))
wf.team + theme_classic() + scale_color_manual(values=c('#999999','#E69F00'))
produces this plot
the
problem is:
- i needed to format "Datum" Column as factor since this code
data$Datum <- as.Date(data$Datum, format="%d.%m.%Y")
gave me NAs in the "Datum" column. I dont know why it didnt used to do so
- The
"Datum" x-axis is still not readable even though i did:
"theme(axis.text.x = element_text(angle = 50, size = 10, vjust = 0.5))"