[R] getting values from arrays using which()

Frede Aakmann Tøgersen FredeA.Togersen at agrsci.dk
Thu Jul 5 12:36:02 CEST 2007


ndx <- which(myArray>=99 , ind.arr=T)

cbind(ndx, myArray[ndx])



Best regards

Frede Aakmann Tøgersen
Scientist


UNIVERSITY OF AARHUS
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology
Blichers Allé 20, P.O. BOX 50
DK-8830 Tjele

Phone:   +45 8999 1900
Direct:  +45 8999 1878

E-mail:  FredeA.Togersen at agrsci.dk
Web:	   http://www.agrsci.org				

This email may contain information that is confidential.
Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed.
If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email.



Med venlig hilsen
Frede Aakmann Tøgersen
 

 

> -----Oprindelig meddelelse-----
> Fra: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] På vegne af Jabez Wilson
> Sendt: 5. juli 2007 12:21
> Til: R-Help
> Emne: [R] getting values from arrays using which()
> 
> Dear R-Help,
> 
> I have an array 1260x1260, upper triangle consisting of 
> numbers between 0 and 100, and lower triangle all NA. I can 
> extract the index of those values say above 99 using the 
> following code:
> which(myArray>=99 , ind.arr=T)
> 
> which returns:
>        row  col
> 5475   252  253
> 45423  764  765
> 46902  777  778
> 34146  611  962
> 50681 1220 1221
> 
> Now I would like to if poss print the actual value contained 
> in the index as well so it would look like:
> 
>        row  col
> 5475   252  253    99  
> 45423  764  765    96.5    
> 46902  777  778    99
> 34146  611  962    100    
> 50681 1220 1221    100
> 
> Can this be done?
> 
> 
>       ___________________________________________________________ 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list