I have a dataset with the following format:
descriptors
1: D112_M|D40_M|D70_M|D107_M|D152_M|D116_M|D190_M|D62_M|D71_M|D182_M|
2: D17_P|D21_P|D23_P|D25_P|D30_P|D22_P|D37_P|D39_P|D44_P
3: D17_P|D21_P|D23_P|D25_P|D30_P|D22_P|D37_P|D39_P|
4: D17_P|D21_P|D23_P|D25_P|D30_P|D22_P
5: D112_M|D40_M|D70_M|D107_M|D152_M|D116_M|
6: D112_M|D40_M|D70_M|D107_M|D152_M|D116_M
hit_descriptors
1: 1|0|1|1|1|1|0|0|0|0
2: 0|0|0|0|0|0|1|1|2
3: 0|1|1|0|0|1|3|0
4: 1|2|1|1|2|2
5: 0|1|1|0|0|0
6: 0|1|1|1|0|1
It is necessary to transform the column descriptors into columns and the variable descriptors_acertos into values of these columns. How can I do this transformation?
I tried a function:
t2_hit <- str_split(t2$descriptores_hit,
pattern = "|",
n = str_count(t2$hit_descriptors, pattern = ""),
simplify = T)
t2_hit <- as.data.table(t2_hit)
But give error.