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. thanks F.J
Hi Did you try help.search("abs") gives me abs(base) Miscellaneous Mathematical Functions meanabsdev(cluster) Internal cluster functions absolute.size(grid) Absolute Size of a Grob abs.error.pred(hmisc) Indexes of Absolute Prediction Error for Linear Models corresp(MASS) Simple Correspondence Analysis crabs(MASS) Morphological Measurements on Leptograpsus Crabs loglm1(MASS) Fit Log-Linear Models by Iterative Proportional Scaling -- Internal function quine(MASS) Absenteeism from School in Rural New South Wales HTML(R2HTML) Outputs an object to a HTML file mad(stats) Median Absolute Deviation xtabs(stats) Cross Tabulation filePathAsAbsolute(tools) File Utilities or ?abs You should enhance your search utility Cheers Petr On 29 Apr 2004 at 22:56, Fred J. wrote:> 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. > > thanks > F.J > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
Are you looking for Re() and friends? Toy examples:> abs(Re(3+4i))[1] 3> abs(Re(-3+4i))[1] 3> abs(Re(3))[1] 3 see ?complex for further details on complex numbers in R vito ----- Original Message ----- From: Fred J. <phddas at yahoo.com> To: r help <r-help at stat.math.ethz.ch> Sent: Friday, April 30, 2004 7:56 AM Subject: [R] absolute value> 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. > > thanks > F.J > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html
"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