I have the following character:
endvotes <- "Yes106No85EH2NT6ES0P1"
I would like to get data.framelike this
Yes No EH NT ES P
106 85 2 6 0 1
I know how to break each of them, for example:
yes <- unlist(str_split(end_votes, "\\No"))[1]
yes <- as.integer(unlist(str_split(yes, "Yes"))[2])
yes
[1] 106
I think that one of the possibilities would be to divide by position, but the numbers (one, two or three digits) are not always the same, so I would like to separate the answers (yes, no, etc.). Of course, I could do this for each answer (as indicated above), but I'm sure there is a more elegant way. Can someone tell me how this is done beautifully? Thanks
source
share