pcplot: Principal Component Plots

Description Usage Arguments Examples

View source: R/R/pcplot.R View source: R/pcplot.R

Description

Takes a data set and plots principal components against each other with ggplot.

Usage

1
2
pcplot(data, xpc, ypc, cor = TRUE, control = FALSE, group = NA,
  labelled = FALSE, biplot = FALSE)

Arguments

data

A set of predictor values

xpc

Principal component to plot along the x-axis

ypc

Principal compenent to plot along y-axis

cor

Indicates to use correlation for PCA. Defaults to TRUE

control

Indicates if user wants to customize ggplot rather than the default setting. Defaults to FALSE.

group

A vector indicating which group the observation belongs to. Defaults to NA.

labelled

Indicates whether or not to label the observations. Defaults to FALSE.

biplot

Allows user to plot vectors of loadings of each variable

Examples

1
2
3
4
5
6
7
library(ggplot2)
data("USArrests")
pcplot(USArrests, 1, 2, labelled = TRUE)

data("longley")
longley$Group <- ifelse(longley$Year <= 1954, "a", "b")
pcplot(longley[,-c(6:8)], 1, 2, group = longley$Group, labelled = TRUE)

seijikoike/pcplot documentation built on May 22, 2019, 10:55 p.m.