I have repeated values in column a and I want these to become new row with information from column b.
I've tried the tidyr function for gather and spread
library("tidyr")
rearrangeddf<-spread(df,a,b)
#Input
a=c("A","A","A","A","A","B","B","B","B","B")
b=c(1,2,3,4,5,11,12,13214634,14,15432)
df=data.frame(a,b)
#Output
x=c("A",1,2,3,4,5)
y=c("B",11,12,13214634,14,1543)
rearrangeddf=rbind(x,y)
Error: Each row of output must be identified by a unique combination of keys. Keys are shared for 10 rows: * 1, 2, 3, 4, 5 * 6, 7, 8, 9, 10 Do you need to create unique ID with tibble::rowid_to_column()? Call
rlang::last_error()
to see a backtrace