canonical_correlation {stxplore}R Documentation

Computes transformed variables from Canonical Correlation Analysis using a dataframe or a stars object

Description

Computes Canonical Correlation Analysis (CCA) using 2 datasets. The autoplot function plots the output.

Usage

canonical_correlation(x1, x2, ...)

## S3 method for class 'data.frame'
canonical_correlation(x1, x2, ...)

## S3 method for class 'stars'
canonical_correlation(x1, x2, ...)

## S3 method for class 'cancor'
autoplot(object, xlab = "Time", ...)

Arguments

x1

The first dataframe or stars object.

x2

The second dataframe or stars objext. The dimensions of both datasets need to be the same.

...

Other arguments currently ignored.

object

For autoplot: the output of the function ‘cannonical_correlation’.

xlab

For autoplot: the xlabel to appear on CCA plot.

Value

A canonical correlation object.

Examples

# Dataframe example
df1 <- SSTdatashort[1:100, ]
df2 <- SSTdatashort[401:500, ]
ccor <- canonical_correlation(df1, df2)
autoplot(ccor)

# stars example
library(stars)
tif = system.file("tif/olinda_dem_utm25s.tif", package = "stars")
x <- read_stars(tif)
x1 <- x[[1]][1:50, 1:50]
x2 <- x[[1]][51:100, 1:50]
stx1 <- st_as_stars(x1)
stx2 <- st_as_stars(x2)
canonical_correlation(stx1, stx2)


[Package stxplore version 0.1.0 Index]