Learn R Programming

Rrepest (version 1.5.2)

weighted.corr: Weighted bivariate correlation

Description

Computes the weighted Pearson correlation coefficient of two numeric vectors.

Usage

weighted.corr(x, y, w, na.rm = TRUE)

Value

Scalar containing the Pearson correlation coefficient

Arguments

x

(numeric vector) Variable of interest x for computing the correlation

y

(numeric vector) Variable of interest y for computing the correlation

w

(numeric vector) Vector with the weights

na.rm

(bool) if TRUE: Excludes missing values before computing the correlation

Examples

Run this code
data(df_talis18) 

weighted.corr(x = df_talis18$t3stake, y = df_talis18$t3team, w = df_talis18$tchwgt)

Run the code above in your browser using DataLab