plot_pca: plot_pca

View source: R/plot_pca.R

plot_pcaR Documentation

plot_pca

Description

plot PCA

Usage

plot_pca(
  pc,
  metadata,
  colourby = "none",
  shapeby = "none",
  group = "none",
  continuous = FALSE,
  pcs = c("PC1", "PC2")
)

Arguments

pc

prcomp object

metadata

metadata dataframe

colourby

colour by. default "none"

shapeby

shape by. default "none"

group

group aes in ggplot. default "none"

continuous

is colourby a continuous variable? default FALSE

pcs

principal components to plot. default c("PC1", "PC2")

Value

list of ggplot pca plot and corresponding dataframe used to make the plot

Examples

pca_result <- prcomp(USArrests, scale = TRUE)
state_data <- data.frame(abb = state.abb, area = state.area,
                         center = state.center, region = state.region,
                         division = state.division)
rownames(state_data) <- state.name
plot_pca(pca_result, state_data, colourby='division', shapeby='region')

OxfordCMS/OCMSutility documentation built on Feb. 27, 2025, 8:19 p.m.