R: Miscellaneous Mathematical Functions (original) (raw)
MathFun {base} | R Documentation |
---|
Description
abs(x)
computes the absolute value of x, sqrt(x)
computes the (principal) square root of x, \sqrt{x}
.
The naming follows the standard for computer languages such as C or Fortran.
Usage
abs(x)
sqrt(x)
Arguments
x | a numeric or complex vector or array. |
---|
Details
These are internal generic primitive functions: methods can be defined for them individually or via the[Math](../../base/help/S3groupGeneric.html)
group generic. For complex arguments (and the default method), z
, abs(z) ==[Mod](../../base/help/Mod.html)(z)
and sqrt(z) == z^0.5
.
abs(x)
returns an [integer](../../base/help/integer.html)
vector when x
isinteger
or [logical](../../base/help/logical.html)
.
S4 methods
Both are S4 generic and members of the[Math](../../methods/html/S4groupGeneric.html)
group generic.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.
See Also
[Arithmetic](../../base/help/Arithmetic.html)
for simple, [log](../../base/help/log.html)
for logarithmic,[sin](../../base/help/sin.html)
for trigonometric, and [Special](../../base/help/Special.html)
for special mathematical functions.
‘plotmath’ for the use of sqrt
in plot annotation.
Examples
require(stats) # for spline
require(graphics)
xx <- -9:9
plot(xx, sqrt(abs(xx)), col = "red")
lines(spline(xx, sqrt(abs(xx)), n=101), col = "pink")
[Package _base_ version 4.6.0 Index]