nested_prcomp: Nested Principal Components Analysis (PCA)

View source: R/nested_prcomp.R

nested_prcompR Documentation

Nested Principal Components Analysis (PCA)

Description

Powered by prcomp. When creating the nested_data, the data should be scaled (i.e, trans = scale) if all variables are not in the same unit.

Usage

nested_prcomp(.data, data_column = .data$data, ...)

Arguments

.data

A data frame with a list column of data frames, possibly created using nested_data.

data_column

An expression that evalulates to the data object within each row of .data

...

Passed to prcomp.

Value

.data with additional columns 'model', 'loadings', 'variance' and 'scores'

Examples

library(dplyr, warn.conflicts = FALSE)

nested_pca <- alta_lake_geochem %>%
  nested_data(
    qualifiers = c(depth, zone),
    key = param,
    value = value,
    trans = scale
  ) %>%
  nested_prcomp()

# get variance info
nested_pca %>% unnested_data(variance)

# get loadings info
nested_pca %>% unnested_data(loadings)

# scores, requalified
nested_pca %>% unnested_data(c(qualifiers, scores))


paleolimbot/tidypaleo documentation built on Jan. 25, 2023, 2:43 a.m.