principal_components_result Provides easy access to principal component analysis results

principal_components_result(data, results = 2)

Arguments

data

list output from principal_components

results

principal component analysis results to extract. Can use either results name or number (i.e. pca_loadings or 2):

  1. pca_sdev

  2. pca_loadings (default)

  3. pca_rotated

  4. pca_center

  5. pca_scale

Value

Returns one of the selected results:

  1. pca_sdev: the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the correlation matrix, though the calculation is actually done with the singular values of the data matrix).

  2. pca_loadings: the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors).

  3. pca_rotated: if retx is TRUE the value of the rotated data (the centred (and scaled if requested) data multiplied by the rotation matrix) is returned. Hence, cov(x) is the diagonal matrix diag(sdev^2).

  4. pca_center: the centering used

  5. pca_scale: whether scaling was used

See also

principal_components for computing the principal components results

Examples

# An efficient means for getting principal component analysis results x <- matrix(rnorm(200 * 3), ncol = 10) principal_components(x) %>% principal_components_result(pca_loadings)
#> PC1 PC2 PC3 PC4 PC5 PC6 #> [1,] 0.01405973 -0.08552135 0.35728397 -0.32497603 0.14808795 -0.05341820 #> [2,] -0.10858457 -0.29008905 0.01082899 0.43840443 0.44303283 -0.65507383 #> [3,] -0.35870618 -0.21869798 0.32004445 0.04496394 0.47526480 0.24674299 #> [4,] 0.15532451 0.50566478 0.60369139 0.03332388 0.11551437 0.02148220 #> [5,] 0.06085332 0.31957453 -0.13700342 0.31783308 0.34125121 0.33829138 #> [6,] -0.03615198 0.18169912 0.31641814 0.15750830 0.08652226 0.05839856 #> [7,] 0.57812948 0.14101767 -0.35516438 -0.27686654 0.57591704 -0.02741530 #> [8,] 0.60914028 -0.51990675 0.23794500 0.41512704 -0.14000790 0.32210720 #> [9,] -0.33269236 0.04591033 -0.31559933 0.30311065 0.11766713 0.45139254 #> [10,] 0.11931477 0.42139002 -0.06408025 0.48204934 -0.23131142 -0.28384832 #> PC7 PC8 PC9 PC10 #> [1,] -0.51156814 0.02566120 -0.007354907 -0.68704372 #> [2,] -0.07036894 0.28222281 0.004631522 0.04146394 #> [3,] 0.26055845 -0.56146709 0.219537859 0.03097183 #> [4,] 0.18794706 0.39454083 0.363683735 0.13253747 #> [5,] -0.67143570 -0.09532397 -0.053533924 0.28409383 #> [6,] 0.21004400 -0.00759615 -0.883891698 -0.06642252 #> [7,] 0.28819303 -0.06216487 -0.036303803 -0.14971240 #> [8,] 0.01417035 0.02516943 0.042656190 -0.06072649 #> [9,] 0.21566939 0.44552582 0.088511754 -0.47464447 #> [10,] 0.07360540 -0.48646524 0.156075179 -0.41378267