cor R Documentation

## Correlation, Variance and Covariance (Matrices)

### Description

`cov` and `cor` compute the covariance or correlation of `x` and `y` if these are vectors. If `x` and `y` are matrices then the covariances (or correlations) between the columns of `x` and the columns of `y` are computed.

### Usage

```## S4 method for signature 'fm'
var(x, y = NULL, na.rm = FALSE, use)

## S4 method for signature 'fm'
cor(x, y = NULL, use = "everything", method = c("pearson",
"kendall", "spearman"))

## S4 method for signature 'fm'
cov(x, y = NULL, use = "everything", method = c("pearson",
"kendall", "spearman"))
```

### Arguments

 `x` a numeric vector or matrix `y` `NULL` (default) or a vector or matrix with compatible dimensions to `x`. The default is equivalent to `y=x`. `use` an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings `"everything"`, `"all.obs"`, `"complete.obs"`, `"na.or.complete"`, or `"pairwise.complete.obs"`. `method` a character string indicating which correlation coefficient (or covariance) is to be computed. One of `"pearson"` (default), `"kendall"`, or `"spearman"`: can be abbreviated. Right now this argument isn't used.

### Examples

```mat <- fm.runif.matrix(100, 10)
var(mat)
cor(mat)
cov(mat)
```