Given a list of characters, such as:
L <- list("a", "b", "c", "d")
Note that, the length of L is not fixed.
How can I get adjacent pairs of combination, such as:
[,1] [,2]
[1,] "a" "b"
[2,] "b" "c"
[3,] "c" "d"
Actually,I do this job to get a directed matrix for further network analysis. U know, in a specific computer-mediated communication, people discuss with each other one by one, there is a sequence, new comer only reply to the latest post.
Andrie’s use of embed is certainly elegant and probably more efficient. Here’s a slightly more clumsy method: