I would like to do the following in R (but am open to suggestions in bash): I have a long list of elements (20,000) that are part of 80 groups. Each group starts with the same string before the underscore delimiter. I want to split the column of all elements into a new data frame containing 80 columns, according to the pattern before the underscore. The columns will have different sizes, so NA values are acceptable.
E.g. the column I want to split:
head(df$V1)
FOO1_Yu
FOO1_uN
FOO2_Yo
FOO2_yA
FOO10_nO
FOO10_Yes
FOO1_NoY
Desired outcome (a new df, with headers included in the first row):
head(df2)
FOO1 FOO2 FOO10
FOO1_Yu FOO2_Yo FOO10_nO
FOO1_uN FOO2_yA FOO10_Yes
FOO1_NoY
Any ideas? (And thanks in advance!)