I have a data frame that looks like this:
a b 1 x 8 2 x 6 3 y 3 4 y 4 5 z 5 6 z 6
and I want to turn it into this:
x y
Somehow like this?
df <- data.frame(ind = rep(1:min(table(df$a)), length(unique(df$a))), df) df %>% spread(a, b) %>% select(-ind) ind x y z 1 1 8 3 5 2 2 6 4 6