cor_wo_shared_zero: Correlation without shared zeros

Description Usage Arguments Details Value Examples

View source: R/cor_wo_shared_zero.R

Description

Remove positions where x=y=0 and then compute correlation.

Usage

1

Arguments

x

a numeric vector with positive or null entries.

y

a numeric vector with positive or null entries.

...

arguments to be passed to cor such as method (see details).

Details

For method: one of "pearson" (default), "kendall", or "spearman".

Value

The estimated correlation coefficient between x and y after removing shared zeros.

Examples

1
2
3
4
x <- c(0, 7, 5, 0, 2)
y <- c(8, 0, 0, 0, 2)
cor_wo_shared_zero(x, y, method = "spearman")
cor(x[-4], y[-4], method = "spearman")

abichat/correlationtree documentation built on March 11, 2020, 3:55 p.m.