Trying to learn some R after doing mostly Haskell for rather a long time I got stuck on a problem I would usually have using unzip1 and map.
I have a sequence of strings, each containing two substrings separated by an underscore. I want to “unzip” this sequence into something like a data frame or a matrix, where the first column is the sequence of all the first substrings and the second column the sequence of all the second substrings.
Is there any analogue to unzip in R, and would it be considered ideomatic to use it here, or am I approaching this from alltogether the wrong direction?
[1] Given a list (or more generally any kind of sequence) of pairs unzip produces a pair of lists, in the obvious way.
You’re on the right track. You want
strsplitthats a list.. and sapply will get the vectors out.