
Correlation
corr.RdCompute the correlation of observed and predicted data.
Details
This is a convenience function to the stats::cor() function.
See cor documentation for further details.
Optional parameters are sent to cor. The most important are:
usean optional character giving a method for computing covariances in the presence of missing values. This must be one of the strings "everything", "all.obs", "complete.obs", "na.or.complete", or "pairwise.complete.obs". Seecordocumentation for further details.methoda character string indicating which correlation coefficient to be computed. One of "pearson" (default), "kendall" or "spearman".
Examples
# Generate two random temperature series in the range of 20, 30 (for testing purpose):
x <- runif(n = 10, min = 20, max = 30)
y <- runif(n = 10, min = 20, max = 30)
corr(x, y)
#> [1] 0.542282
if (FALSE) { # \dontrun{
# temperature is a data.frame with obs and pred columns:
corr(temperature$obs, temperature$pred, use = "complete.obs")
# temperature is a data.table with obs and pred columns:
temperature[, .(corr(obs, pred, use = "complete.obs")), by = cod_brace]
} # }