plot_PCA: Plot the PCA result with ggplot

Description Usage Arguments Value Examples

View source: R/plot_PCA.R

Description

Plots the PCA result from a 'rda' object in package 'vegan' with 'ggplot2'. Note that the terminology in the descriptions follow that in 'vegan.'

Usage

1
2
3
4
5
6
7
8
9
plot_PCA(
  rda_object,
  scaling = 1,
  sites_addins = NULL,
  species_addins = NULL,
  sites_label,
  sites_color,
  species_color
)

Arguments

rda_object

The 'rda' object calculated by 'vegan'.

scaling

The scaling of the PCA result. In breif, scaling = 1 illustrates the distance between sites. scaling = 2 illustrates the correlation between species.

sites_addins

The factored information for sites.

species_addins

The factored information for species.

sites_label

The column in the 'sites_addins' for showing the labels of the sites.

sites_color

The column in the 'sites_addins' for changing the colors of sites

species_color

A character with the length of 1 to change the coloring of species.

Value

A ggplot object. Any further 'theme' manipulations can be directly added following the ggplot grammar.

Examples

1
2
3
4
5
data(iris)
values <- iris[-5] # extract numerical values from `iris`
normalized <- scale(values) # normalize the values
pca_iris <- rda(normalized) # returns a "rda" object
plot_PCA(pca_iris, sites_addins = iris[5], sites_label = "Species", sites_color = "Species")

chenyenting1998/ecomaestro documentation built on Dec. 19, 2021, 3:04 p.m.