[R] absolute value

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Apr 30 09:56:40 CEST 2004


"Fred J." <phddas at yahoo.com> writes:

> Hello
> 
> could you please tell me what is the function to get
> the absolute value of the real or complex number.
> most of other languages it is abs(x) , what is it in
> r?
> 
> I did few searhces in the help docs for no avail.

Will you believe it?

> abs(1+1i)
[1] 1.414214

In the complex case some may prefer Mod(x) which does the same thing.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list