So I am a bit of an R novice, I am trying to plot a graph that has multiple line each colour coded. My data is currently in the format of 3 columns (Name,Total, Year) and 270 rows. There is 15 years for each name and the data looks something similar to this:
Name Year Total
X 1 4
Y 1 6
Z 1 3
I want each name to have its own line running from the first year in the data to the last with the totals being plotted. I am however unaware how to separate out each of these names to ensure that they are plotted separately. My data is currently in a tab delimited text file from excel. I was wondering how to proceed from here. Any help is appreciated
With tidyverse
it should look like this:
library(tidyverse)
df %>%
ggplot(aes(x = Year, y = Total, color = Name)) +
geom_line()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.