# need this
library(aqp)
# generate 10 random profiles with default settings:
d.list <- lapply(1:10, function(i) random_profile(i))
d <- do.call('rbind', d.list)
# convert to SoilProfileList and plot
# add a fake color
d$soil_color <- 'white'
# if the plotrix package is installed,
# make a more interesting color based on the first property
if(require(plotrix))
d$soil_color <- color.scale(d$p1, c(0,1,1),c(1,1,0),0)
# convert to SoilProfileList object
d <- initProfileList(d)
profile_plot(d)
# simple cluster analysis:
d.list <- lapply(1:10, function(i) random_profile(i))
d <- do.call('rbind', d.list)
p <- profile_compare(d, vars=c('p1','p2','p3'), max_d=50, k=0)
plot(hclust(p))
# stress-test profile comparison functions (not run)
# d.list <- lapply(1:1000, function(i) random_profile(i))
# d <- do.call('rbind', d.list)
# rm(d.list)
# 67 seconds on 1.3 Ghz Intel Mac Mini -- D matrix = 192.3 Mb
# more efficient computation, at the expense of precision, with
# p <- profile_compare(d, vars=c('p1','p2','p3','p4','p5'),
# max_d=50, k=0, sample_interval=10)
# compare with
# p <- profile_compare(d, vars=c('p1','p2','p3','p4','p5'), max_d=50, k=0)
Run the code above in your browser using DataLab