j***3 发帖数: 142 | 1 there are N names (e.g. "A", "B", ...)
and there are a list of N*N scores (not ordered) of each directional pair
of names.
e.g.
AA 0
AB 2
AC 0
AD 3
...
how to make a matrix from the list so that:
[,A] [,B] [,C] .....
[A,] 0 2 0
[B,] 2 1 2
[C,] 0 1 2
.....
many thanks | b*****n 发帖数: 685 | | o**m 发帖数: 828 | 3 如果是有规则的, 那就
matrix(secondcolumn, N,N)
【在 j***3 的大作中提到】 : there are N names (e.g. "A", "B", ...) : and there are a list of N*N scores (not ordered) of each directional pair : of names. : e.g. : AA 0 : AB 2 : AC 0 : AD 3 : ... : how to make a matrix from the list so that:
| a********s 发帖数: 188 | 4 Use "unlist" and then "matrix". | s*r 发帖数: 2757 | | j***3 发帖数: 142 | 6 thank all for suggestions, it is easy with a simple perl script, but I just
wondering if I can do it directly in R.
there is a related question that might be easier in R, I hope, that is how I
can do it the other way, namely, from a known matrix and generate the list
of score for each pairs of names? |
|