I need to arrange the table into following format to make others clear to see which name is duplicate and the corresponding value
#original df
df <- data.frame(name=c('a','a','a','b','b'),
value=(c(1,2,3,4,5)),stringsAsFactors = FALSE)
#df
name value
a 1
a 2
a 3
b 4
b 5
#target df
name1 value1 name2 value2 name3 value3
a 1 a 2 a 3
b 4 b 5 NA NA
Wish the solution can extend columns automatically. If 'a' is duplicated 4 times then the target df should be 8 columns (4 pairs of 'name' and 'value')
Thank you