Skip to contents

pca_decision plots the explained variances against the number of the principal component. In addition, it returns all the information about the PCA performance.

Usage

pca_decision(x, ncomp = 30, norm = T, matrix_mode = "S-mode")

Arguments

x

data.frame. A data.frame with the following variables: x, y, time, value, var, units. See as_synoptReg.

ncomp

integer. Number of principal components to show/retain

norm

logical. Default TRUE. norm = TRUE is recommended for classify two ore more variables.

matrix_mode

character. The mode of matrix to use. Choose between S-mode and T-mode

Value

a list with:

  • A list with class princomp containing all the results of the PCA

  • A data frame containing the main results of the ncomp selected (standard deviation, proportion of variance and cumulative variance).

  • A ggplot2 object to visualize the scree test

Note

To perform the PCA the x must contain more rows than columns. In addition, x cannot contain NA values.

See also

Examples

# Load data (mslp or precp_grid)
data(msl)
data(z500)

# Joining both variables
atmos_data <- dplyr::bind_rows(msl,z500)

# Deciding on the number of PC to retain
info <- pca_decision(atmos_data, norm = TRUE)