[R] Odp: Closest value

Petr PIKAL petr.pikal at precheza.cz
Wed Aug 27 15:22:45 CEST 2008


Hi

r-help-bounces at r-project.org napsal dne 27.08.2008 15:12:58:

> 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

E.g.
which.min((x.axis-3.2)^2)

Regards
Petr

> 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