Re: [R] incidence and adjacency matrix conversion
Thanks, David. I tried converting my rectangular matrix to a network object and then back to a square matrix. This works for a small artificial dataset (e.g. 2x5), but when I try this on my 1790x45 or transposed 45x1790 matrix, R keeps working for a couple of minutes and then crashes completely without having saved any data first. I assume something is wrong with my data? Cheers Philip David Barron wrote: I think you can do this using the network package. Look at the as.network.matrix and as.matrix.network functions, for example. how can I convert an m x n incidence matrix into an m x m adjacency matrix or an n x n adjacency matrix? The current matrix contains binary data, hence the new matrix would contain counts of common occurrences. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] incidence and adjacency matrix conversion
Thanks, David. I tried converting my rectangular matrix to a network object and then back to a square matrix. This works for a small artificial dataset (e.g. 2x5), but when I try this on my 1790x45 or transposed 45x1790 matrix, R keeps working for a couple of minutes and then crashes completely without having saved any data first. I assume something is wrong with my data? Cheers Philip David Barron wrote: I think you can do this using the network package. Look at the as.network.matrix and as.matrix.network functions, for example. how can I convert an m x n incidence matrix into an m x m adjacency matrix or an n x n adjacency matrix? The current matrix contains binary data, hence the new matrix would contain counts of common occurrences. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] incidence and adjacency matrix conversion
Phil == Philip Leifeld [EMAIL PROTECTED] on Tue, 05 Dec 2006 22:30:02 +0100 writes: Phil Dear all, Phil how can I convert an m x n incidence matrix into an m x m adjacency Phil matrix or an n x n adjacency matrix? The current matrix contains binary Phil data, hence the new matrix would contain counts of common occurrences. You have not given a self contained reproducible example which would even be useful in such a case.. But just to be sure that the solution is not as simple as I thought it was -- namely I thought, that for binary matrices, crossprod() and tcrossprod() would give what you'd want : n - 10 ; m - 4 set.seed(1) M - matrix(as.logical(rbinom(n*m, size=1, prob = 0.3)), n,m) symnum(M) [1,] . . | . [2,] . . . . [3,] . . . . [4,] | . . . [5,] . | . | [6,] | . . . [7,] | | . | [8,] . | . . [9,] . . | | [10,] . | . . print.table(A.1 - tcrossprod(M), zero = .) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]1.......1 . [2,]......... . [3,]......... . [4,]...1.11.. . [5,]....2.211 1 [6,]...1.11.. . [7,]...121311 1 [8,]....1.11. 1 [9,]1...1.1.2 . [10,]....1.11. 1 print.table(A.2 - crossprod(M), zero = .) [,1] [,2] [,3] [,4] [1,]31.1 [2,]14.2 [3,]..21 [4,]1213 Phil Thank you for your help. you're welcome (if it did help). Martin Maechler, ETH Zurich __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] incidence and adjacency matrix conversion
Dear all, how can I convert an m x n incidence matrix into an m x m adjacency matrix or an n x n adjacency matrix? The current matrix contains binary data, hence the new matrix would contain counts of common occurrences. Thank you for your help. Phil __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] incidence and adjacency matrix conversion
I think you can do this using the network package. Look at the as.network.matrix and as.matrix.network functions, for example. On 05/12/06, Philip Leifeld [EMAIL PROTECTED] wrote: Dear all, how can I convert an m x n incidence matrix into an m x m adjacency matrix or an n x n adjacency matrix? The current matrix contains binary data, hence the new matrix would contain counts of common occurrences. Thank you for your help. Phil __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.