pcaviz.Rd
Creates a "pcaviz" data structure from PCA results (e.g.,
prcomp
output, and accompanying data. The data
structure is specifically designed to facilitate plotting PCA results
and relationships between estimated principal components and related
data (e.g., geographic co-ordinates).
pcaviz(out.pca, x = NULL, sdev = NULL, var = NULL, rotation = NULL, dat = NULL, pc.cols) # S3 method for pcaviz summary(object, …) # S3 method for summary.pcaviz print(x, n = 4, …) # S3 method for pcaviz print(x, n = 4, …)
out.pca | Output of |
---|---|
x | For function "pcaviz", this is a matrix or data frame
containing the data samples projected onto the principal components
(also sometimes referred to as "rotated data" or "scores"). This is
equivalent to the |
sdev | Optional vector containing the standard deviations of the
PCs or, equivalently, the square root of the eigenvalues. This is
the same as the |
var | Optional value specifying the total variance. This should
be equal to the sum of the variances of the individual PCs. It can
be computed as |
rotation | Optional matrix or data frame containing the
eigenvectors (alternatively called "variable loadings" or
"rotation matrix"). This is can be chosen as the |
dat | Optional data frame supplying additional information about
the data samples. It should be a data frame with one row for each
data sample, and should have as many rows as the rotated data.
Optionally, this data frame may also supply the rotated data, as
indicated by input |
pc.cols | Indicates which columns of input |
object | An object of class |
n | Maximum number of variables of each category to display in the summary. |
… | Additional print and summary arguments. These additional arguments are not used here. |
pcaviz
returns a list with class "pcaviz"
containing the
following components:
Data frame containing the rotated variables as well as accompanying data.
Names of the columns in data
that contain
the rotated variables.
If not NULL
, this is a vector containing the
standard deviations of the PCs; equivalently, the square roots of
the eigenvalues.
If not NULL
, this is a data frame containing
the eigenvectors ("loadings") and, optionally, other data columns.
A matrix with one column per PC that is used to keep track of the principal axes after transformation.
A logical value indicating whether at least one transformation (e.g., a rotation) has been applied to the PCs. Initially set to FALSE.
summary.pcaviz
, pcaviz-plots
,
prcomp
, princomp
,
rpca
, pcaviz-transformations
# Create pcaviz object from prcomp output. data(iris) a1 <- pcaviz(prcomp(iris[1:4]),dat = iris) # Create pcaviz object from princomp output. a2 <- pcaviz(princomp(iris[1:4]),dat = iris) # An alternative way to create pcaviz object from prcomp output. out <- prcomp(iris[1:4]) a3 <- pcaviz(x = out$x,sdev = out$sdev,var = sum(out$sdev^2), rotation = out$rotation,dat = iris)# NOT RUN { # Print summaries of the pcaviz objects. summary(a1) summary(a2) summary(a3) # These vignettes demonstrate various ways pcaviz objects # can be created. vignette("iris") vignette("popres") vignette("regmap") # }