(no subject)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

R help mailing list-2
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Jeremie Juste
malika yassa via R-help <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Jeremie Juste


Hello,

Be sure to include the mailing list,<[hidden email]> 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 <[hidden email]> 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 <[hidden email]> a écrit :  
>
>  malika yassa via R-help <[hidden email]> 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]]
>>
>> ______________________________________________
>> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Bert Gunter-2
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 <[hidden email]>
wrote:

>
>
> Hello,
>
> Be sure to include the mailing list,<[hidden email]> 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 <[hidden email]> 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 <
> [hidden email]> a écrit :
> >
> >  malika yassa via R-help <[hidden email]> 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]]
> >>
> >> ______________________________________________
> >> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.