I have a dataset with presence-absence (1-0) data and concentrations of (13) heavy metals from 70 ponds and I'm trying to asses which heavy metals affect newt presence in different ponds so I made a PCA biplot. I want to visualise in which ponds newts are present and absent so that I can see which heavy metals are more linked to presence or absence by adding symbols (e.g. circles, triangles, ...) that correspond with the presence or absence of the newts in ponds. I'm working in Rstudio. You will really help me out! Thank you in advance for your answers!
I used following code to create the PCA biplot, but did not find how to add symbols in this.
# Putting heavy metals for PCA in new vector
heavymetals<-cbind(Newts[,24:38], Newts[,40:46])
heavymetals
# Creating biplot
cor(heavymetals, method = 'spearman')
library(vegan)
heavymetals_model<-rda(heavymetals,scale=TRUE)
biplot(heavymetals_model)
summary(heavymetals_model)
screeplot(heavymetals_model)
Next I tried to make a PCA biplot using my limited knowledge of ggplot2 and asked AI for some help but it didn't get me anywhere...
Without the
Newts
data or PCA object, we'll start with creating an example.Load packages
Principal Component Analysis on Palmer Penguins data
Create a scatterplot of first two PC
Create a plot of the loadings
Created on 2023-12-12 with reprex v2.0.2