Covariance
Description
Calculates the covariance between two columns / expressions.
Usage
pl$cov(a, b, ddof = 1)
Arguments
a
|
One column name or Expr or anything convertible Intopl$col() .
|
b
|
Another column name or Expr or anything convertible Intopl$col() .
|
ddof
|
integer Delta Degrees of Freedom: the divisor used in the calculation is N - ddof, where N represents the number of elements. By default ddof is 1. |
Value
Expr for the computed covariance
Examples
library("polars")
lf = as_polars_lf(data.frame(a = c(1, 8, 3), b = c(4, 5, 2)))
lf$select(pl$cov("a", "b"))$collect()
#> shape: (1, 1)
#> ┌─────┐
#> │ a │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 3.0 │
#> └─────┘
#> [1] 3