Learn R Programming

SparkR (version 2.1.2)

cov: cov

Description

Compute the sample covariance between two expressions.

Calculate the sample covariance of two numerical columns of a SparkDataFrame.

Usage

cov(x, ...)

covar_samp(col1, col2)

# S4 method for characterOrColumn cov(x, col2)

# S4 method for characterOrColumn,characterOrColumn covar_samp(col1, col2)

# S4 method for SparkDataFrame cov(x, colName1, colName2)

Arguments

x

a Column or a SparkDataFrame.

...

additional argument(s). If x is a Column, a Column should be provided. If x is a SparkDataFrame, two column names should be provided.

col1

the first Column.

col2

the second Column.

colName1

the name of the first column

colName2

the name of the second column

Value

The covariance of the two columns.

See Also

Other math_funcs: acos, asin, atan2, atan, bin, bround, cbrt, ceil, conv, corr, cosh, cos, covar_pop, expm1, exp, factorial, floor, hex, hypot, log10, log1p, log2, log, pmod, rint, round, shiftLeft, shiftRightUnsigned, shiftRight, signum, sinh, sin, sqrt, tanh, tan, toDegrees, toRadians, unhex

Other stat functions: approxQuantile, corr, crosstab, freqItems, sampleBy

Examples

Run this code
# NOT RUN {
cov(df$c, df$d)
cov("c", "d")
covar_samp(df$c, df$d)
covar_samp("c", "d")
# }
# NOT RUN {
df <- read.json("/path/to/file.json")
cov <- cov(df, "title", "gender")
# }

Run the code above in your browser using DataLab