Thanks for the reproducible example.
Because this mixes numeric and character data, it's better done as a
data frame than a matrix.
> data.frame(rowind=as.vector(row(m)), colind=as.vector(col(m)), value =
> as.vector(m))
rowind colind value
1 1 1 a
2 2 1 b
3
Hi All,
I have a matrix like
m <- matrix( letters[1:10], ncol=5)
How to conver it to 10 * 3 matrix, which the first col is row index of m,
second col is colum index of m and third column is the value of matrix, say
11 1"a"
21 2 "c"
1 3 "e"
etc...
Thanks.
2 matches
Mail list logo