
pca(X, ncomp = 3, center = TRUE, scale = FALSE,
comp.tol = NULL, max.iter = 500, tol = 1e-09)
ncomp
decides the number of components and associated
eigenvalues to display from the pcasvd
algorithm and if the data has missing values,
ncomp
gives the number of components to kX
can be supplied.
The value is passed to sca
FALSE
for consistency with prcomp
function, but in general scaling is advisable. Alpca
returns a list with class "pca"
and "prcomp"
containing the following components:retx
is true the value of the rotated data (the centred (and scaled if requested) data
multiplied by the rotation matrix) is returned.FALSE
.princomp
, the print method for these objects prints the results in a nice format and the
plot
method produces a bar plot of the percentage of variance explaned by the principal
components (PCs).Note that scale= TRUE
cannot be used if there are zero or constant (for center = TRUE
) variables.
Components are omitted if their standard deviations are less than or equal to comp.tol
times
the standard deviation of the first component. With the default null setting, no components are omitted.
Other settings for comp.tol
could be comp.tol = sqrt(.Machine$double.eps)
,
which would omit essentially constant components, or comp.tol = 0
.
nipals
, prcomp
, biplot
,
plotIndiv
, plotVar
,
plot3dIndiv
, plot3dVar
and http://www.math.univ-toulouse.fr/~biostat/mixOmics/ for more details..data(multidrug)
## this data set contains missing values, therefore
## the 'prcomp' function cannot be applied
pca.res <- pca(multidrug$ABC.trans, ncomp = 4, scale = TRUE)
plot(pca.res)
print(pca.res)
biplot(pca.res, xlabs = multidrug$cell.line$Class, cex = 0.7)
# samples representation
plotIndiv(pca.res, ind.names = multidrug$cell.line$Class, cex = 0.5,
col = as.numeric(as.factor(multidrug$cell.line$Class)))
plot3dIndiv(pca.res, cex = 0.2,
col = as.numeric(as.factor(multidrug$cell.line$Class)))
# variables representation
plotVar(pca.res, var.label = TRUE)
plot3dVar(pca.res, rad.in = 0.5, var.label = TRUE, cex = 0.5)
Run the code above in your browser using DataLab