Description Usage Arguments Value See Also Examples
Plot score for prcomp
(PCA) result
1 2 3 4 |
prcompResult |
output object from |
xPC |
an integer indicating PC component on x-axis |
yPC |
an integer indicating PC component on y-axis |
group |
a vector of numeric, character or factor class separating the samples into groups. Correspond to point color. |
group2 |
The second group, can be a vector of numeric, character or factor class separating the samples into groups. Correspond to point shape. |
cex |
(optional) size of points on graphs |
cex.legend |
(optional) size of fonts in legend |
label |
(optional) a character vector or expression specifying the text to be written. |
pos |
(optional, applicable when label is given) a position specifier for the text. If specified this overrides any adj value given. Values of 1, 2, 3 and 4, respectively indicate positions below, to the left of, above and to the right of the specified coordinates. |
col |
point color palette |
pch |
point type palette |
legendlocation |
(optional)location of legend on graph.
Look up |
legendoutside |
(optional) set to TRUE if you want to put legend on the outside of the plot. The legend location is defaulted to topright. |
rightwhitespace |
(optional) set width for white space for legend. Only applicable if legendoutside = TRUE |
... |
additional arguments for |
A figure is returned on the graphic device
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | data(applejuice)
applejuice_uf <- unfold(applejuice) # unfold list into matrix
result <- prcomp(applejuice_uf)
plotScore(result) # plot PC1 vs PC2 score
plotScore(result, pch = 3, col = "blue") # change shape and color
# get country of apple production
country <- sapply(strsplit(names(applejuice), split = "-"), "[", 1)
plotScore(result, label = country) # add label
# or plot by group
plotScore(result, xPC = 1, yPC = 3, group = country)
# custom point types and color
plotScore(result, xPC = 1, yPC = 3, group = country, pch = c(1,2), col = c("green", "black"))
# move legend outside
plotScore(result, xPC = 1, yPC = 3, group = country, legendoutside = TRUE)
# two groups
cultivar <- sapply(strsplit(names(applejuice), split = "-"), "[", 2)
plotScore(result, group = country, group2 = cultivar)
# make the points more transparent
## Not run:
require(scales)
plotScore(result, group = country, group2 = country, col = alpha(generateColor(2), 0.7))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.