-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCODA_example.R
23 lines (20 loc) · 1.07 KB
/
CODA_example.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require(compositions)
# Compositional analysis setup --------------------------------------------
fpart <- names(wetdat[c(13:17, 19:21, 23:24)])
cdata <- wetdat[fpart]
cdata$Fv <- 1000000-rowSums(cdata[fpart]) ## calculates "fill value" (Fv), in mg/kg soil
scoda <- acomp(cdata)
# Sequential binary partion & isometric log ratio (ilr) transform
bpart <- t(matrix(c( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,-1,
-1,-1,-1,-1,-1, 1, 1, 1, 1, 1, 0,
-1,-1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 1,-1,-1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,-1, 0, 0, 0, 0, 0, 0,
1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1,-1, 1,-1, 0,
0, 0, 0, 0, 0,-1, 1, 0,-1, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,-1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0,-1, 0), ncol=11, nrow=10, byrow=T))
CoDaDendrogram(X=acomp(scoda), signary=bpart, type="lines") ## compositional balance mobile graph
idata <- as.data.frame(ilr(scoda, V=bpart))
wetdat <- cbind(wetdat, idata)