if (requireNamespace("igraph")) {
# load sample data set
data(amador)
# create weighted adjacency matrix (see ?component.adj.matrix for details)
m <- component.adj.matrix(amador)
# plot network diagram, with Amador soil highlighted
plotSoilRelationGraph(m, s='amador')
# dendrogram representation
plotSoilRelationGraph(m, s='amador', plot.style='dendrogram')
# compare methods
m.o <- component.adj.matrix(amador, method='occurrence')
op <- par(no.readonly = TRUE)
par(mfcol=c(1,2))
plotSoilRelationGraph(m, s='amador', plot.style='dendrogram')
title('community matrix')
plotSoilRelationGraph(m.o, s='amador', plot.style='dendrogram')
title('occurence')
# investigate max spanning tree
plotSoilRelationGraph(m, spanning.tree='max')
# investigate max spanning tree + edges with weights > 75-th pctile
plotSoilRelationGraph(m, spanning.tree=0.75)
par(op)
# \donttest{
if(requireNamespace("curl") &
curl::has_internet() &
require(soilDB)) {
# get similar data from soilweb, for the Pardee series
s <- 'pardee'
d <- siblings(s, component.data = TRUE)
# normalize component names
d$sib.data$compname <- tolower(d$sib.data$compname)
# keep only major components
d$sib.data <- subset(d$sib.data, subset=compkind == 'Series')
# build adj. matrix and plot
m <- component.adj.matrix(d$sib.data)
plotSoilRelationGraph(m, s=s, plot.style='dendrogram')
# alter plotting style, see ?plot.phylo
plotSoilRelationGraph(m, s=s, plot.style='dendrogram', type='fan')
plotSoilRelationGraph(m, s=s, plot.style='dendrogram',
type='unrooted', use.edge.length=FALSE)
}
# }
}
Run the code above in your browser using DataLab