Here is my dataframe
df2 <- structure(list(Code = c("ICB-9_label_1", "1", "2", "3",
"4", "5", "1", "ICB-10_label_2", "3", "4", "5",
"1", "2", "3", "3", "5", "1", "2",
"3", "4", "5", "1", "2", "3", "4",
"5", "1", "2", "3", "4", "5", "1",
"2", "3", "4", "5", "1", "2", "3",
"4", "5", "1", "2", "3", "4", "5",
"1"), Description = c("description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here", "description here", "description here", "description here",
"description here")), row.names = c(NA, -47L), class = c("tbl_df",
"tbl", "data.frame"))
And here is what it looks like as a table:
Code Description
ICB-9_label_1 description here
1 description here
2 description here
3 description here
4 description here
5 description here
1 description here
ICB-10_label_2 description here
3 description here
4 description here
I'd like to create a third column called "Labels". It would say "ICB_9_label_1" all the way down until it hits the row number for "ICB_10_label_2", then the column would say "ICB_10_label_2" all the way down. I don't want to override the numbers in the first column, since the 1, 2, 3, 4, 5 values are important.