R - Math Functions
R Code |
Examples |
Function |
a + b |
|
Addition |
a - b |
|
Subtraction |
a * b |
|
Multiplication |
a / b |
|
Division |
2 + 4 * 5 |
|
Order of Operations |
abs(a-b) |
|
Absolute Value |
factorial(x) |
|
Factorial of x (x!) |
x^n |
|
x raised to the nth power |
xen |
|
x * 10n |
log10(x) |
|
Common logarithm of x with base 10 |
log(x, n) |
|
Logarithm of x with base n |
log(x) |
|
Natural logarithm with base e (2.1782) |
exp(n) |
|
Exponential function: en |
sqrt(x) |
|
Square root of x |
floor(x) |
|
Rounds x down |
ceiling(x) |
|
Rounds x up |
pi |
|
3.141593 |
round(x, n) |
|
Round a number x to n decimal places |
round(pi, 0) |
|
Round pi to a whole number |
round(pi, n) |
|
Round pi to n decimal places |
cos(x) |
|
Cosine of x |
sin(x) |
|
Sine of x |
tan(x) |
|
Tangent of x |
acos(x) |
|
Inverse cosine (arccosine)of x |
asin(x) |
|
Inverse sine (arcsine) of x |
atan(x) |
|
Inverse tangent (arctangent) of x |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.