Hi I'm new to the RStudio community,
This is a really newby question. But say if I have a column X which indicates 10 categories delimited by ","
E.g.
row 1: c1,c3,c10
row 2: c2,c7,c10
row 3: c1,c2,c3
How would I go about creating 10 columns, each are indicators for which is in X
E.g. (new columns are 1 to 10, left to right)
row 1: 1,0,1,0,0,0,0,0,0,1
row 2: 0,1,0,0,0,0,1,0,0,1
row 3: 1,1,1,0,0,0,0,0,0,0
I know I can do a for loop to scan through each row and split X by delimiter ",".
Then have 10 if statements that checks for the new columns. But is there a more efficient way for this? I imagine wither bigger data sets this could get computational difficult.
Thanks for the help!