extract PC percents from rda object in R

77 views Asked by At

I'm looking to add the principal component percentages to my graph but I'm unsure how to calculate/extract these values from the rda object.

library(vegan)

all.std <- na.omit(decostand(all.data, method = "normalize"))
all.rda <- rda(all.std)

# extract info for viz
uscores.all <- data.frame(all.rda$CA$u)
uscores.all <- rownames_to_column(uscores.all,"sample.id")
uscores1.all <- inner_join(icp.metadata,uscores.all, by = "sample.id")
vscores.all <- data.frame(all.rda$CA$v)

I have the sample points and vector information that gives me a good image with the full data, but how do I add the % for PC1 and PC2?

all.data <- data.frame(
  Al.308.215 = c(
    1933.110774, 2124.933186, 2697.142811, 2454.099034, 2416.374341, 2730.405337,
    2846.957744, 2957.419342, 2959.348363, 2853.258817
  ),
  Al.396.152 = c(
    1955.47859, 2142.707892, 2719.348431, 2475.607238, 2428.867771, 2759.503064,
    2875.096669, 2990.04952, 2988.810866, 2880.507931
  ),
  Ba.233.527 = c(
    4.758488077, 4.873488218, 5.496073131, 5.322604493, 5.334528828, 5.519915915,
    5.715194792, 5.774621594, 7.152332657, 7.157559445
  ),
  Ba.455.404 = c(
    4.676267981, 4.748689692, 5.424586334, 5.246081426, 5.233062678, 5.41001526,
    5.639145829, 5.687752522, 7.029890126, 7.058378483
  ),
  Ca.183.801 = c(
    659.0148918, 655.0216397, 705.7125714, 699.3610886, 685.2562524, 682.351838,
    667.2459663, 666.5119829, 451.5861085, 430.0641182
  ),
  Ca.317.933 = c(
    663.2478342, 660.1603433, 706.2024694, 704.5687867, 685.9959824, 687.0625639,
    670.5308695, 667.5984284, 448.1139829, 428.0179807
  ),
  Fe.259.941 = c(
    902.8585447, 911.2101809, 1017.666402, 1022.594904, 1048.51115, 1002.091143,
    970.8258109, 905.2628883, 997.8037721, 1046.38376
  ),
  K.766.491 = c(
    314.1726307, 309.757608, 389.1136882, 376.3265692, 373.4714432, 413.0336628,
    420.9373827, 437.5226928, 475.3400126, 477.8208541
  ),
  Mg.285.213 = c(
    510.5124552, 596.0268573, 829.8716737, 768.2083155, 744.1670151, 784.4661692,
    796.7464128, 837.234733, 684.5431608, 707.3844484
  ),
  Mn.257.611 = c(
    15.91777975, 15.88328987, 17.680152, 17.57143193, 18.39642397, 17.96018218,
    17.69058768, 17.24667962, 19.92596564, 20.23646264
  ),
  row.names = c("2A", "4A", "5A", "6A", "7A", "8A", "9A", "10A", "11A", "12A")
)
1

There are 1 answers

0
Geomicro On BEST ANSWER

seems I was misusing the vegan::rda function, and have since clarified my needs using this great tutorial:

https://r.qcbs.ca/workshop10/book-en/redundancy-analysis.html