(no subject)
Jeremie's suggestion of course will fail if some of the off-diagonal elements are the same as those on the diagonals. The request doesn't make a lot of sense to me, but if "m" is the matrix, m[row(z) != col(z)] reliably extracts the vector of non-diagonal entries, which can then be dimensioned as desired. Or upper.tri() and lower.tri() can be used to separately extract the upper and lower triangle entries via logical indexing. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Oct 20, 2018 at 8:48 AM Jeremie Juste <jeremiejuste at gmail.com> wrote:
Hello,
Be sure to include the mailing list,<r-help at r-project.org> when you
reply. In this way to improve your chances of obtaining a good answer
and everyone benefits.
May be something like this ?
aa <- matrix(1:9,3,3)
matrix(as.numeric(aa)[!as.numeric(aa) %in% diag(aa)],2,3)
[,1] [,2] [,3]
[1,] 2 4 7
[2,] 3 6 8
Hope it helps,
Jeremie
malika yassa <yassa_malika at yahoo.fr> writes:
hellow
yes i want to extract the non-diagonal part
for exampl
i have this matrix [,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9the result
[,1] [,2] [,3]
[1,] 2 4 7
[2,] 3 6 8
Le samedi 20 octobre 2018 ? 15:21:53 UTC+2, Jeremie Juste <
jeremiejuste at gmail.com> a ?crit :
malika yassa via R-help <r-help at r-project.org> writes: Hello, Can you specify what you mean by deleting exactly? Do you want to have zero in the diagonal or do you want to extract the non-diagonal part? Besides your matrix is not a square matrix. Do you really want to extract the non-diagonal part of a non square matrix? Best regards, Jeremie
hellowplease,do you help mei have this matrixm<-matrix(( 1:12, nrow = 3
)
I want to delete the diagonal values of this matrix
can anyone do thisthinks
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.