I have sample vector like this:
v <- c(1, 2, 1, 3, 2, 3, 3, 4, 1, 4)
What I’d like to get is frequency table which will tell me frequencies of numbers followed by another numbers .
Output:
1 2 3 4
1 0 1 0 1
2 1 0 1 0
3 1 1 1 0
4 1 0 1 0
And then the same values in percentages.
If I’m thinking what you are meaning is correct, try:
This doesn’t match with your expected output, but I’m not sure how you arrived at that.
For percentages, use
prop.table: