[R] Closest value

Doran, Harold HDoran at air.org
Wed Aug 27 15:23:08 CEST 2008


Maybe this
which.min(abs(x.axis-3.2)) 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Dani Valverde
> Sent: Wednesday, August 27, 2008 9:13 AM
> To: R Help
> Subject: [R] Closest value
> 
> Hello,
> I have this command:
> x.axis <- seq(from=0.5, to=4.5, length.out=13112) How can I 
> which of the x.axis components is the closest to a given 
> value, for example 3.2?
> Best,
> 
> Dani
> 
> --
> Daniel Valverde Saubí
> 
> Grup de Biologia Molecular de Llevats
> Facultat de Veterinària de la Universitat Autònoma de 
> Barcelona Edifici V, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
> 
> Centro de Investigación Biomédica en Red en Bioingeniería, 
> Biomateriales y Nanomedicina (CIBER-BBN)
> 
> Grup d'Aplicacions Biomèdiques de la RMN Facultat de 
> Biociències Universitat Autònoma de Barcelona Edifici Cs, Campus UAB
> 08193 Cerdanyola del Vallès- SPAIN
> +34 93 5814126
> 
> ______________________________________________
> R-help at r-project.org 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