Learn R Programming

ggfacto (version 0.3.2)

PCA2: Principal Component Analysis

Description

A user-friendly wrapper around PCA, made to work better with ggfacto functions like ggpca_cor_circle. All variables can be selected by many different expressions, in the way of the `tidyverse`. No supplementary vars are to be provided here, since they can be added afterward.

Usage

PCA2(
  data,
  active_vars,
  wt,
  col.w = NULL,
  ind_name,
  scale.unit = TRUE,
  ind.sup = NULL,
  ncp = 5,
  graph = FALSE,
  ...
)

Value

A `res.pca` object, with all the data necessary to draw the PCA.

Arguments

data

The data frame.

active_vars

<tidy-select> The names of the active variables.

wt

The name of the row weight variable

col.w

The weights of the columns, as a numeric vector of the same length than `active_vars.`

ind_name

Possibly, a variable with the names of the individuals.

scale.unit

A boolean, if `TRUE` (value set by default) then data are scaled to unit variance.

ind.sup

A vector indicating the indexes of the supplementary individuals.

ncp

Number of dimensions kept in the results (by default 5).

graph

A boolean, set to `TRUE` to display the base graph.

...

Additional arguments to pass to PCA.

Examples

Run this code
active_vars <- c("mpg", "cyl", "hp", "drat", "qsec")
res.pca <- PCA2(mtcars, tidyselect::all_of(active_vars) )

Run the code above in your browser using DataLab