My apologies for the bit hard to understand title of this question, I will try to explain what I mean with some example data. I have a text column in a data frame with rows that look like this:
2,413 European ancestry cases, 2,392 European ancestry controls, 810 African American
2,731 European ancestry cases, 10,747 European ancestry controls
8,918 European ancestry individuals, 3,947 Indian Asian ancestry individuals
175 Han Chinese ancestry cases, 175 Han Chinese ancestry controls
Preferably, I would like to turn this single column into multiple numerical columns, and have the column names be the words that follow every number. So the results from the four rows above would be:
European ancestry cases, European ancestry controls, African American, European ancestry individuals, Indian Asian ancestry individuals, Han Chinese ancestry cases, Han Chinese ancestry controls
2413, 2392, 810 , NA, NA, NA, NA
2731, 10747, NA, NA, NA, NA, NA
NA, NA, NA, 8918, 3947, NA, NA
NA, NA, NA, NA, NA, 175, 175
Any ideas on how to accomplish this in R?