compute_correlation: Compute a Spearman correlation test between two variables

Description Usage Arguments Value Note See Also Examples

View source: R/correlations.R

Description

This function computes the Spearman correlation between two variables. It is a simple wrapper around the R function cor.test, with better display of the output.

Usage

1
compute_correlation(var1, var2)

Arguments

var1

A vector.

var2

A vector.

Value

A vector containing the correlation between two variables, the p-value of the correlation test, and the sample size after discarding the missing values.

Note

We set the argument exact to FALSE in the call to cor.test, so that the presence of ties in some correlation tests would not change how the p-values are computed (exact tests are not possible in the presence of ties for this implementation of the test). Otherwise p-values obtained can sometimes be inconsistent across tests (ex: smaller p-values despite higher rho and same sample size.)

See Also

compute_correlation_table

Examples

1
compute_correlation(var1 = males$Mat_succ, var2 = males$Rep_succ)

courtiol/matingRhinos documentation built on Nov. 22, 2019, 11:10 p.m.