Learn R Programming

ecodist (version 2.1.3)

cor2m: Two-matrix correlation table

Description

Generate a correlation table between the variables of two data sets, originally for comparing species abundances and environmental variables.

Usage

cor2m(x, y, trim = TRUE, alpha = 0.05)

Value

Returns a data frame of correlations between the variables of 2 data frames.

Arguments

x

A matrix or data frame of environmental (or other) variables matching the sites of x

y

A matrix or data frame of species (or other) variables

trim

If trim is TRUE, set rho<critical value(alpha) to 0

alpha

alpha p-value to use with trim, by default 0.05

Author

Dean Urban

Details

cor2m generates a correlation table between the variables of two matrices. The original use case is to compare species abundances and environmental variables. It results in a data frame with species (or the first matrix) as columns and environmental variables (or the second matrix) as rows, so it's easy to scan. Correlations less than a user-specified alpha (0.05 by default) can be set to NA. cor2m generates a correlation table between the variables of two matrices. The original use case is to compare species abundances and environmental variables. The result has species (or the first matrix) as columns and environmental variables (or the second matrix) as rows, so it's easy to scan. Correlations less than a user-specified alpha can be set to NA. If trim, correlations less than the critical value for the provided alpha are set to to NA. The critical value is computed as a t-test with n-2 df. cor2m(x, y, trim=FALSE) is equivalent to cor(x, y)

Examples

Run this code
data(graze)
speciesdata <- graze[, 3:7]
envdata <- graze[, 1:2]
sppenv.cor <- cor2m(envdata, speciesdata)
print(sppenv.cor, na.print="")

Run the code above in your browser using DataLab