Dear Group,
I have the following matrix
m
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    0    2    1  Inf  Inf  Inf  Inf  Inf
[2,]    1    0    2  Inf  Inf  Inf  Inf  Inf
[3,]    2    1    0  Inf  Inf  Inf  Inf  Inf
[4,]    3    2    1    0  Inf  Inf  Inf  Inf
[5,]  Inf  Inf  Inf  Inf    0  Inf  Inf  Inf
[6,]  Inf  Inf  Inf  Inf    1    0  Inf  Inf
[7,]  Inf  Inf  Inf  Inf  Inf  Inf    0  Inf
[8,]    1    3    2  Inf  Inf  Inf    1    0

I want  all values grater than 0 = to 1 and zero other wise?
thanks in advance
so 
this used, 
m <-ifelse(  (m==0)||  is.infinite(m),0, 1   )

but it gave me  zero   result
replacing
|| with | ,make sense and return the matrix I was looking for.

what is the difference betwen boht || an | ? when to use each ?

thanks in advance
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to