I actually have a data frame with 2000 rows (different days), each row contains a character ”vector” containing binary info on 30 different skills. If the skill has been used its number appear in the vector. But to simplify:
If I have a data frame with 3 observations (3 days) of 10 different skills -named "S_total"
:
S_total= [1,3,7,8,9,10], [5,9], []
, and a variable Day= 1,2,3
I'd like to construct a dataframe with 3 rows and 12 columns
The columns being: Day,S_total,,s1,s,2,s3,s4,s5,s6,s7,s8,s9,s10
Where the numbered variables could be of the format true/false
.
I have thought in the direction of as.numeric(read.csv)
and then a for
-loop containing cbind
.
But there must be a better way ? tidy verse? I could hope for someone demonstrating: regular expression and the Map-command