Learn R Programming

EEM (version 1.1.1)

plotScorem: Plot score matrix for prcomp result based on group

Description

Plot score matrix for prcomp (PCA) result based on group

Usage

plotScorem(prcompResult, ncomp = 4, group, cex = 1.5, col = NULL, pch = NULL, legendtitle = NULL, ...)

Arguments

prcompResult
output object from prcomp function
ncomp
maximum number of PC score to plot
group
a vector of numeric, character or factor class separating the samples into groups.
cex
(optional) size of points on graphs
col
point color palette
pch
point type palette
legendtitle
legend title
...
additional arguments to be passed on to pairs

Value

A figure is returned on the graphic device

See Also

pairs, plotScore

Examples

Run this code
data(applejuice)
# country of apple production
country <- sapply(strsplit(names(applejuice), split = "-"), "[", 1)

applejuice_uf <- unfold(applejuice) # unfold list into matrix
result <- prcomp(applejuice_uf) 
# plot PC1 vs PC3 score based on country of production
plotScorem(result, ncomp = 4, group = country) 

# specify colours
plotScorem(result, ncomp = 4, group = country, col = c("black", "grey"))

Run the code above in your browser using DataLab