Math functions defined for Column
.
bin(x)bround(x, ...)
cbrt(x)
ceil(x)
conv(x, fromBase, toBase)
hex(x)
hypot(y, x)
pmod(y, x)
rint(x)
shiftLeft(y, x)
shiftRight(y, x)
shiftRightUnsigned(y, x)
signum(x)
degrees(x)
toDegrees(x)
radians(x)
toRadians(x)
unhex(x)
# S4 method for Column
abs(x)
# S4 method for Column
acos(x)
# S4 method for Column
acosh(x)
# S4 method for Column
asin(x)
# S4 method for Column
asinh(x)
# S4 method for Column
atan(x)
# S4 method for Column
atanh(x)
# S4 method for Column
bin(x)
# S4 method for Column
cbrt(x)
# S4 method for Column
ceil(x)
# S4 method for Column
ceiling(x)
# S4 method for Column
cos(x)
# S4 method for Column
cosh(x)
# S4 method for Column
exp(x)
# S4 method for Column
expm1(x)
# S4 method for Column
factorial(x)
# S4 method for Column
floor(x)
# S4 method for Column
hex(x)
# S4 method for Column
log(x)
# S4 method for Column
log10(x)
# S4 method for Column
log1p(x)
# S4 method for Column
log2(x)
# S4 method for Column
rint(x)
# S4 method for Column
round(x)
# S4 method for Column
bround(x, scale = 0)
# S4 method for Column
signum(x)
# S4 method for Column
sign(x)
# S4 method for Column
sin(x)
# S4 method for Column
sinh(x)
# S4 method for Column
sqrt(x)
# S4 method for Column
tan(x)
# S4 method for Column
tanh(x)
# S4 method for Column
toDegrees(x)
# S4 method for Column
degrees(x)
# S4 method for Column
toRadians(x)
# S4 method for Column
radians(x)
# S4 method for Column
unhex(x)
# S4 method for Column
atan2(y, x)
# S4 method for Column
hypot(y, x)
# S4 method for Column
pmod(y, x)
# S4 method for Column,numeric
shiftLeft(y, x)
# S4 method for Column,numeric
shiftRight(y, x)
# S4 method for Column,numeric
shiftRightUnsigned(y, x)
# S4 method for Column,numeric,numeric
conv(x, fromBase, toBase)
Column to compute on. In shiftLeft
, shiftRight
and
shiftRightUnsigned
, this is the number of bits to shift.
additional argument(s).
base to convert from.
base to convert to.
Column to compute on.
round to scale
digits to the right of the decimal point when
scale
> 0, the nearest even number when scale
= 0, and scale
digits
to the left of the decimal point when scale
< 0.
abs
: Computes the absolute value.
acos
: Returns the inverse cosine of the given value,
as if computed by java.lang.Math.acos()
acosh
: Computes inverse hyperbolic cosine of the input column.
asin
: Returns the inverse sine of the given value,
as if computed by java.lang.Math.asin()
asinh
: Computes inverse hyperbolic sine of the input column.
atan
: Returns the inverse tangent of the given value,
as if computed by java.lang.Math.atan()
atanh
: Computes inverse hyperbolic tangent of the input column.
bin
: Returns the string representation of the binary value
of the given long column. For example, bin("12") returns "1100".
cbrt
: Computes the cube-root of the given value.
ceil
: Computes the ceiling of the given value.
ceiling
: Alias for ceil
.
cos
: Returns the cosine of the given value,
as if computed by java.lang.Math.cos()
. Units in radians.
cosh
: Returns the hyperbolic cosine of the given value,
as if computed by java.lang.Math.cosh()
.
exp
: Computes the exponential of the given value.
expm1
: Computes the exponential of the given value minus one.
factorial
: Computes the factorial of the given value.
floor
: Computes the floor of the given value.
hex
: Computes hex value of the given column.
log
: Computes the natural logarithm of the given value.
log10
: Computes the logarithm of the given value in base 10.
log1p
: Computes the natural logarithm of the given value plus one.
log2
: Computes the logarithm of the given column in base 2.
rint
: Returns the double value that is closest in value to the argument and
is equal to a mathematical integer.
round
: Returns the value of the column rounded to 0 decimal places
using HALF_UP rounding mode.
bround
: Returns the value of the column e
rounded to scale
decimal places
using HALF_EVEN rounding mode if scale
>= 0 or at integer part when scale
< 0.
Also known as Gaussian rounding or bankers' rounding that rounds to the nearest even number.
bround(2.5, 0) = 2, bround(3.5, 0) = 4.
signum
: Computes the signum of the given value.
sign
: Alias for signum
.
sin
: Returns the sine of the given value,
as if computed by java.lang.Math.sin()
. Units in radians.
sinh
: Returns the hyperbolic sine of the given value,
as if computed by java.lang.Math.sinh()
.
sqrt
: Computes the square root of the specified float value.
tan
: Returns the tangent of the given value,
as if computed by java.lang.Math.tan()
.
Units in radians.
tanh
: Returns the hyperbolic tangent of the given value,
as if computed by java.lang.Math.tanh()
.
toDegrees
: Converts an angle measured in radians to an approximately equivalent angle
measured in degrees.
degrees
: Converts an angle measured in radians to an approximately equivalent angle
measured in degrees.
toRadians
: Converts an angle measured in degrees to an approximately equivalent angle
measured in radians.
radians
: Converts an angle measured in degrees to an approximately equivalent angle
measured in radians.
unhex
: Inverse of hex. Interprets each pair of characters as a hexadecimal number
and converts to the byte representation of number.
atan2
: Returns the angle theta from the conversion of rectangular coordinates
(x, y) to polar coordinates (r, theta),
as if computed by java.lang.Math.atan2()
. Units in radians.
hypot
: Computes "sqrt(a^2 + b^2)" without intermediate overflow or underflow.
pmod
: Returns the positive value of dividend mod divisor.
Column x
is divisor column, and column y
is the dividend column.
shiftLeft
: Shifts the given value numBits left. If the given value is a long value,
this function will return a long value else it will return an integer value.
shiftRight
: (Signed) shifts the given value numBits right. If the given value is a long
value, it will return a long value else it will return an integer value.
shiftRightUnsigned
: (Unsigned) shifts the given value numBits right. If the given value is
a long value, it will return a long value else it will return an integer value.
conv
: Converts a number in a string column from one base to another.
# NOT RUN {
# Dataframe used throughout this doc
df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))
tmp <- mutate(df, v1 = log(df$mpg), v2 = cbrt(df$disp),
v3 = bround(df$wt, 1), v4 = bin(df$cyl),
v5 = hex(df$wt), v6 = degrees(df$gear),
v7 = atan2(df$cyl, df$am), v8 = hypot(df$cyl, df$am),
v9 = pmod(df$hp, df$cyl), v10 = shiftLeft(df$disp, 1),
v11 = conv(df$hp, 10, 16), v12 = sign(df$vs - 0.5),
v13 = sqrt(df$disp), v14 = ceil(df$wt))
head(tmp)
# }
Run the code above in your browser using DataLab