f_pca: calculate principle components for a dataset

Description Usage Arguments Details Value See Also Examples

View source: R/f_pca.R

Description

This function is an extended wrapper for prcomp(). I takes a data_ls object created by f_clean_data and calculates the contribution of each variable to each principle component in percent.

Usage

1
2
f_pca(data_ls, center = T, scale = T, use_boxcox_tansformed_vars = T,
  include_ordered_categoricals = T)

Arguments

data_ls

data_ls object generated by f_clean_data(), or a named list list( data = <dataframe>, numericals = < vector with column names of numerical columns>)

center

boolean, Default: T

scale

boolean, Default: T

use_boxcox_tansformed_vars

boolean, Default: T

include_ordered_categoricals

boolean, Default: T

Details

Blog post explaining how to calculate contributions

Value

a list with the original data complemented with the principle component vector data of each observation and an object returned by prcomp() supplemented with some extra features

data

dataframe

pca

pca object created by prcomp()

added features of pca:

cos2

The squared rotation vectors.A value between 0 and 1 denotes the amount of contribution of a variable to a specific principle component

vae

percent variance explained

contrib_abs_perc

The absolute contribution of one variable to the variance explained by one principle component in percent. The total contibution adds up to the total contibution of the principle componaent in percent.

contrib_abs_perc_reduced

as above but variables contibuting less than 2.5 percent are grouped

threshold_vae_for_pc_perc

principle components that explain less percent variance than this threshold are dropped

See Also

prcomp

Examples

1
2
3
pca_ls = f_clean_data(mtcars) %>%
f_boxcox() %>%
f_pca()

erblast/oetteR documentation built on April 5, 2018, 9:03 a.m.