biplot3: Draw scores as points with colors

Description Usage Examples

Description

I'm too lazy to fix the code so please always specify xcol for this to work

Usage

1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
require(EEM)
data(applejuice)
applejuice_uf <- unfold(applejuice) # unfold list into matrix
# get country of apple production
country <- sapply(strsplit(names(applejuice), split = "-"), "[", 1)

# select peaks
local_peak <- findLocalMax(applejuice, n = 1)
index <- colnames(applejuice_uf) %in% local_peak
applejuice_uf_selectedPeak <- applejuice_uf[,index, drop = FALSE]

# PCA
result <- prcomp(applejuice_uf_selectedPeak)

# create color palette for x points
require(RColorBrewer)
xcol <- brewer.pal(3, "Dark2")
biplot3(result, xlab = prcompname(result ,1), ylab = prcompname(result,2), 
xlabs = country, xcol = xcol)

chengvt/cheng documentation built on May 13, 2019, 3:52 p.m.