reduce_pca: Reduce Dimensionality with PCA

View source: R/dim_reduction.R

reduce_pcaR Documentation

Reduce Dimensionality with PCA

Description

Principal component analysis or (PCA) is a method we can use to reduce high-dimensional data to a low-dimensional space. In other words, we cannot accurately visualize high-dimensional datasets because we cannot visualize anything above 3 features. The main purpose behind PCA is to transform datasets with more than 3 features (high-dimensional) into typically a 2/3 column dataset. Despite the reduction into a lower-dimensional space we still can retain most of the variance or information from our original dataset.

Usage

reduce_pca(
  df,
  n = NULL,
  ignore = NULL,
  comb = c(1, 2),
  quiet = FALSE,
  plot = TRUE,
  ...
)

Arguments

df

Dataframe

n

Integer. Number of dimensions to reduce to.

ignore

Character vector. Names of columns to ignore.

comb

Vector. Which columns do you wish to plot? Select which two variables by name or column position.

quiet

Boolean. Keep quiet? If not, print messages.

plot

Boolean. Create plots?

...

Additional parameters passed to stats::prcomp

Value

List with reduced dataframe and possible plots.

See Also

Other Dimensionality: reduce_tsne()

Other Clusters: clusterKmeans(), clusterOptimalK(), clusterVisualK(), reduce_tsne()

Examples

Sys.unsetenv("LARES_FONT") # Temporal
data("iris")
df <- subset(iris, select = c(-Species))
df$id <- seq_len(nrow(df))
reduce_pca(df, n = 3, ignore = "id")

laresbernardo/lares documentation built on Oct. 23, 2024, 12:05 p.m.