Это то, что вы ищете?
library(tidyverse)
df <- tibble::tribble(
~Px,~T1a_PlantTree_1,~T1a_PlantTree_2,~T1a_PlantTree_3,~T1a_PlantTree_4,~T1a_PlantTree_5,
"P1" , 15 , 40 , 20 , 60 , 58,
"P2" , 15 , 40 , 20 , 60 , 58,
"P3" , 15 , 40 , 20 , 60 , 58,
"P4" , 15 , 40 , 20 , 60 , 58
)
df %>%
pivot_longer(-Px, names_to = "Condition", values_to = "values") %>%
group_by(Condition) %>%
dplyr::summarise(mean_contribution = mean(values)) %>%
ggplot(aes(x = Condition, y = mean_contribution, group = 1)) +
geom_line()