Plot time series with years in different columns
问题 I have the following data frame dt(head,6) : I need to create a graph in which I have the years (2015, 2016, 2017, 2018, 2019) on the x-axis , different columns (W15, W16, W17, W18, W19 - each one relates to one year) on the y-axis. They are all should be grouped by the column TEAM. I tried using ggplot2 to no avail. 回答1: You need to convert your data from wide to long and then use ggplot . Look below; library(tidyverse) dt %>% pivot_longer(., -Team, values_to = "W", names_to = "Year") %>%