get_pca_formula: Get equation formula for loading of PCA result

Description Usage Arguments Value Examples

View source: R/fct_factor_extra.R

Description

Get equation formula for loading of PCA results in MathJax formats which can be display in browser.

Usage

1
get_pca_formula(pca_res, pc_name_prefix = NULL, ncp = Inf, digits = 3)

Arguments

pca_res

An object of class PCA (FactoMineR); prcomp and princomp((stats); pca, dudi(adea4); epPCA(ExPosition).

pc_name_prefix

A character as name prefix of primary components in results, e.g PC for PC1...PCn. Default NULL means use original name of primary components.

ncp

A number of primary components kept in the results. Default Inf means all primary components.

digits

How many significant digits are to be used for coefficient in formula.

Value

A vector of Character of loading formula of Primary Components

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 

# Display formula in uiOutput(ns("pca_result_formula"))
# Server function
output$pca_result_formula <- renderUI({
  pca_res <- prcomp(iris[, -5], scale = TRUE)

  # Get formula of primary components of PCA
  pca_formula <- get_pca_formula(pca_res)

  pca_formula_mathJax <- purrr::map(pca_formula, .f = helpText)

  withMathJax(
    pca_formula_mathJax
  )
})

## End(Not run)

chriszheng2016/zstexplorer documentation built on June 13, 2021, 9:47 a.m.