column_math_functions: Math functions for Column operations

Description Usage Arguments Details Note Examples

Description

Math functions defined for Column.

Usage

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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)

toRadians(x)

unhex(x)

## S4 method for signature 'Column'
abs(x)

## S4 method for signature 'Column'
acos(x)

## S4 method for signature 'Column'
asin(x)

## S4 method for signature 'Column'
atan(x)

## S4 method for signature 'Column'
bin(x)

## S4 method for signature 'Column'
cbrt(x)

## S4 method for signature 'Column'
ceil(x)

## S4 method for signature 'Column'
ceiling(x)

## S4 method for signature 'Column'
cos(x)

## S4 method for signature 'Column'
cosh(x)

## S4 method for signature 'Column'
exp(x)

## S4 method for signature 'Column'
expm1(x)

## S4 method for signature 'Column'
floor(x)

## S4 method for signature 'Column'
hex(x)

## S4 method for signature 'Column'
log(x)

## S4 method for signature 'Column'
log10(x)

## S4 method for signature 'Column'
log1p(x)

## S4 method for signature 'Column'
log2(x)

## S4 method for signature 'Column'
rint(x)

## S4 method for signature 'Column'
round(x)

## S4 method for signature 'Column'
bround(x, scale = 0)

## S4 method for signature 'Column'
signum(x)

## S4 method for signature 'Column'
sign(x)

## S4 method for signature 'Column'
sin(x)

## S4 method for signature 'Column'
sinh(x)

## S4 method for signature 'Column'
sqrt(x)

## S4 method for signature 'Column'
tan(x)

## S4 method for signature 'Column'
tanh(x)

## S4 method for signature 'Column'
toDegrees(x)

## S4 method for signature 'Column'
degrees(x)

## S4 method for signature 'Column'
toRadians(x)

## S4 method for signature 'Column'
unhex(x)

## S4 method for signature 'Column'
hypot(y, x)

## S4 method for signature 'Column'
pmod(y, x)

## S4 method for signature 'Column,numeric'
shiftLeft(y, x)

## S4 method for signature 'Column,numeric'
shiftRight(y, x)

## S4 method for signature 'Column,numeric'
shiftRightUnsigned(y, x)

## S4 method for signature '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.

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.

unhex: Inverse of hex. Interprets each pair of characters as a hexadecimal number and converts to the byte representation of number.

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

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

degrees since 3.0.0

toRadians since 1.4.0

unhex 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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)
## End(Not run)

danzafar/tidyspark documentation built on Sept. 30, 2020, 12:19 p.m.