Consistent subscripting
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | library(subscript)
library(ape)
set.seed(1)
n <- 8 # number of sites
m <- 5 # number of species
env <- data.frame(x = rnorm(n))
coord <- data.frame(lat = rnorm(n), long = rnorm(n))
rownames(env) <- rownames(coord) <- letters[1:n]
traits <- data.frame(z1 = rnorm(m), z2 = rnorm(m))
rownames(traits) <- LETTERS[1:m]
newick <- "((A,(B,E)),(D,C));"
tree <- chronos(compute.brlen(read.tree(text = newick)))
slist <- speciesList(replicate(n, LETTERS[sample.int(m, sample.int(m, 1))]), letters[1:n])
slist <- speciesList(slist)
pdf <- poly.data.frame(env = setDimIds(env, "sites"),
coord = setDimIds(coord, "sites"),
geog = setDimIds(longDist(coord), "sites"),
traits = setDimIds(traits, "species"),
coph = setDimIds(longDist(tree), "species"),
tree = setDimIds(tree, "species"),
slist = setDimIds(slist, c("sites", "species")))
summary(pdf)
dimIdsNested(pdf)
dimIdsConcat(pdf)
dimIdsUnique(pdf)
dNamesNested(pdf)
dNamesConcat(pdf)
dNames(pdf)
ss1 <- ss(pdf, list(species = c("D","C","A"), sites = c("a","e","f")))
ss2 <- ss(pdf, list(sites = c("a","e","f"), species = c("D","C","A")))
ss3 <- ss(pdf, list(c("a","e","f"), c("D","C","A")))
try(ss4 <- ss(pdf, list(c("D","C","A"), c("a","e","f")))) # should be error
ss5 <- ss(pdf, list(species = c("D","C","A")))
nDims(pdf)
nDims(traits) # data frames (perhaps confusingly) have one dimension
nDims(tree)
longDist(tree)
longDist(traits)
reOrder(longDist(tree), dNames(traits)[[1]])
(FPDist <- combineDists(tree, traits, 0.5))
meanPairwiseDist(pdf$slist, setDimIds(FPDist, "species"))
l <- list(env = env,
coord = coord,
geog = dist(coord),
traits = traits,
coph = as.dist(cophenetic(tree)),
tree = tree,
comm = slist)
pdf2 <- as.poly.data.frame(l, 2, verb = TRUE)
summary(pdf2)
dNames(pdf2)
regs <- dbDiversityRegression(slist, # species list
as.dist(cophenetic(pdf$tree)), # phylogenetic distances
dist(pdf$traits), # functional distances
setNames(env$x, rownames(env)) # ecosystem function
)
mean(regs)
coef(regs)
aHpd(regs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.