Chapter 2 Calculating
2.1 Basic operators and functions
R can be used, without any programming, as a powerful calculator. It has all the standard arithmetic operators and functions, which operate on numeric or complex vectors (including scalars, which are vectors of length 1).
Arithmetic operators: The binary arithmetic operators are +, -, *, /, ^ (exponentiation), %% (mod), and %/% (integer division).
Logarithms and exponentials: log (natural log), log10, (base 10 log), log2 (base 2 log), log (x,b) (log of x to base b). log1p(x) computes log(1+x) accurately for |x| << 1.
exp computes the exponential function, and expm1 computes exp(x)-1 accurately for |x| << 1.
Trigonometric functions : cos(x), sin(x), tan(x), acos(x), asin(x), atan(x), ...
Get Using R for Numerical Analysis in Science and Engineering now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.