[R] How to find 5 closest number from matrix having attributes?

sagarnikam123 sagarnikam123 at gmail.com
Thu Apr 26 14:50:30 CEST 2012


i found one clue in our forum, but it can give position for whole matrix,

>n<-read.table(file.choose(),header=T)
>y<-n[,c("1","2","3")]
> my.number=1.12270420185886
> z<-abs(y-my.number)==min(abs(y-my.number))
> which(z)
[1] 19
                                                    
i have uploaded file,which have matrix[21,3] dimension

i want to find at least 5 closest value with letter & also column no
in another way,i want 5 closest single value from matrix with position

uploaded file:- 
http://r.789695.n4.nabble.com/file/n4589728/chocolate_potential_x.txt
chocolate_potential_x.txt 

--
View this message in context: http://r.789695.n4.nabble.com/How-to-find-5-closest-number-from-matrix-having-attributes-tp4589728p4589728.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list