I have a dataframe with several rows that have the same ID number and a column with character values in each row, that I want to split into separate columns.
I want to go from something like this:
id <- rep(1:5, each = 5)
source <- rep(c("One", "Two", "Three", "Four", "Five"), times = 5)
dat_long <- cbind(id, source)
To something like this:
id2 <- rep(1:5)
ess1 <- rep(c("One"), each = 5)
ess2 <- rep(c("Two"), each = 5)
ess3 <- rep(c("Three"), each = 5)
ess4 <- rep(c("Four"), each = 5)
ess5 <- rep(c("Five"), each = 5)
dat_wide <- cbind(id2, ess1, ess2, ess3, ess4, ess5)
I've tried pivot_wider, reshape, separate but haven't found a way of doing what I want to do.