-
Notifications
You must be signed in to change notification settings - Fork 11
/
IntroMultivariateDissectOrdObjects.R
55 lines (43 loc) · 1.44 KB
/
IntroMultivariateDissectOrdObjects.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# An Introduction to R
#
# Devan Allen McGranahan (devan.mcgranahan@gmail.com)
#
# YouTube lectures: https://www.youtube.com/playlist?list=PLKXOvaXmjIGcSHFMe2Wpsaw4yzvWR0AgQ
# github repo: https://github.com/devanmcg/IntroRangeR
#
# Lesson 11.3 - (A) Script for dissecting ordination objects.
# Assumes ordinations etc fit as in Lesson 11.3 script,
# IntroMultivariateGGplotting.R
# Dissecting the vegan ordination object
class(chem_pca)
?cca
str(chem_pca)
chem_pca$CA$eig
chem_pca$CA$u %>% head # CA$u = sites
chem_pca$CA$v %>% head # CA$v = species
# Scores function applies internal scaling to u and v
# This is part of the math within the metric ordination
scores(chem_pca, display = "sites") %>% head
scores(chem_pca, display = "species")
scores(chem_pca, display = "species") %>%
as.data.frame %>%
as_tibble(rownames="nutrient")
# Dissecting the vegan groups/gradient object
class(pca_hd)
?envfit
str(pca_hd)
str(pca_hd$vectors)
pca_hd$vectors$arrows
scores(pca_hd, "vectors")
scores(pca_hd, "vectors") %>%
as.data.frame %>%
round(3) %>%
as_tibble(rownames="gradient")
# Dissecting the gg_ordiplot object
class(pca_gg)
str(pca_gg)
pca_gg$df_ord %>% head
pca_gg$df_spiders %>% head
pca_gg$df_spiders %>%
rename(MDS1 = x, MDS2 = y) %>%
as_tibble