ggpcat: PCA with prcomp and ggplot of select pc score

View source: R/ggpcat.R

ggpcatR Documentation

PCA with prcomp and ggplot of select pc score

Description

This functions returns the list consit of prcom object and ggplot object.

Usage

ggpcat(dat, x, y, scaling, fctr1, fctr2, m.cols, txt, lgnd, main, cumpov)

Arguments

dat

dataframe, matrix or prcomp object

x, y

axis of pca score. The default values 'x=1, y=2' means xaxis for PC1 score and yaxis for PC2 score

scaling

logical: A prcomp argument for scaling or not. The default is "TRUE"

fctr1

factor: for colour of pca. The default value is rep(1,nrow(dat))

fctr2

factor: for x axis of pc-scores (optional)

m.cols

A vector of manual colour for 'ggplot::scale_colour_manual'. (optional)

txt

integer: size of adding text (optional). The default value is NULL.

lgnd

legend position "none","left","right","bottom", and c(1,3). The default is "right".

main

graph title(optional)

cumpov

numeric. A cumulative proportion of variance for graphed pc-scores. The default value is 70

Value

List of prcomp and ggplot object

Examples

# minimum usage
res <- ggpcat(dat = iris[-5], x = 1, y = 2, scaling = TRUE, fctr1 = iris$Species)
summary(res$res.prcmp)
plot(res$gg)
plot(res$gg_pcs)

# manual color
res <- ggpcat(iris[-5], fctr1 = iris$Species, m.cols = 1:3)

## Not run: 
nfpkm <- rskodat::nfpkm
res2 <- ggpcat(nfpkm[-1:-4], fctr1=nfpkm$days, fctr2=nfpkm$days, cumpov=64)
res3 <- ggpcat(nfpkm[-1:-4], fctr1=nfpkm$runs, fctr2=nfpkm$days, cumpov=64)
res4 <- ggpcat(nfpkm[-1:-4], fctr1=nfpkm$runs, fctr2=nfpkm$days, m.cols = 1:3, cumpov=64)

## End(Not run)

shkonishi/rsko documentation built on Feb. 21, 2023, 5:12 a.m.