column_math_functions

0th

Percentile

Math functions for Column operations

Math functions defined for Column.

Usage
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)

toDegrees(x)

toRadians(x)

unhex(x)

# S4 method for Column abs(x)

# S4 method for Column acos(x)

# S4 method for Column asin(x)

# S4 method for Column atan(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 toRadians(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)

Arguments
x

Column to compute on. In shiftLeft, shiftRight and shiftRightUnsigned, this is the number of bits to shift.

...

additional argument(s).

fromBase

base to convert from.

toBase

base to convert to.

y

Column to compute on.

scale

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.

Details

abs: Computes the absolute value.

acos: Returns the inverse cosine of the given value, as if computed by java.lang.Math.acos()

asin: Returns the inverse sine of the given value, as if computed by java.lang.Math.asin()

atan: Returns the inverse tangent of the given value, as if computed by java.lang.Math.atan()

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.

toRadians: 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: (Unigned) 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.

Note

abs since 1.5.0

acos since 1.5.0

asin since 1.5.0

atan since 1.5.0

bin since 1.5.0

cbrt since 1.4.0

ceil since 1.5.0

ceiling since 1.5.0

cos since 1.5.0

cosh since 1.5.0

exp since 1.5.0

expm1 since 1.5.0

factorial since 1.5.0

floor since 1.5.0

hex since 1.5.0

log since 1.5.0

log10 since 1.5.0

log1p since 1.5.0

log2 since 1.5.0

rint since 1.5.0

round since 1.5.0

bround since 2.0.0

signum since 1.5.0

sign since 1.5.0

sin since 1.5.0

sinh since 1.5.0

sqrt since 1.5.0

tan since 1.5.0

tanh since 1.5.0

toDegrees since 1.4.0

toRadians since 1.4.0

unhex since 1.5.0

atan2 since 1.5.0

hypot since 1.4.0

pmod since 1.5.0

shiftLeft since 1.5.0

shiftRight since 1.5.0

shiftRightUnsigned since 1.5.0

conv since 1.5.0

Aliases
  • column_math_functions
  • abs,Column-method
  • abs
  • acos,Column-method
  • acos
  • asin,Column-method
  • asin
  • atan,Column-method
  • atan
  • bin,Column-method
  • bin
  • cbrt,Column-method
  • cbrt
  • ceil,Column-method
  • ceil
  • ceiling,Column-method
  • ceiling
  • cos,Column-method
  • cos
  • cosh,Column-method
  • cosh
  • exp,Column-method
  • exp
  • expm1,Column-method
  • expm1
  • factorial,Column-method
  • factorial
  • floor,Column-method
  • floor
  • hex,Column-method
  • hex
  • log,Column-method
  • log
  • log10,Column-method
  • log10
  • log1p,Column-method
  • log1p
  • log2,Column-method
  • log2
  • rint,Column-method
  • rint
  • round,Column-method
  • round
  • bround,Column-method
  • bround
  • signum,Column-method
  • signum
  • sign,Column-method
  • sign
  • sin,Column-method
  • sin
  • sinh,Column-method
  • sinh
  • sqrt,Column-method
  • sqrt
  • tan,Column-method
  • tan
  • tanh,Column-method
  • tanh
  • toDegrees,Column-method
  • toDegrees
  • toRadians,Column-method
  • toRadians
  • unhex,Column-method
  • unhex
  • atan2,Column-method
  • atan2
  • hypot,Column-method
  • hypot
  • pmod,Column-method
  • pmod
  • shiftLeft,Column,numeric-method
  • shiftLeft
  • shiftRight,Column,numeric-method
  • shiftRight
  • shiftRightUnsigned,Column,numeric-method
  • shiftRightUnsigned
  • conv,Column,numeric,numeric-method
  • conv
Examples
# 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 = toDegrees(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)
# }
Documentation reproduced from package SparkR, version 2.4.6, License: Apache License (== 2.0)

Community examples

Looks like there are no examples yet.