Learn R Programming

aqp (version 0.85)

random_profile: Random Profile

Description

Generate a random soil profile according to set criteria, with correlated depth trends.

Usage

random_profile(id, n = c(3, 4, 5, 6), min_thick = 5,
 max_thick = 30, n_prop = 5)

Arguments

id
a character or numeric id used for this profile
n
vector of possible number of horizons
min_thick
minimum thickness criteria for a simulated horizon
max_thick
maximum thickness criteria for a simulated horizon
n_prop
number of simulated soil properties (columns in the returned dataframe)

Value

  • A dataframe with the simulated profile.

References

http://casoilresource.lawr.ucdavis.edu/

See Also

profile_compare

Examples

Run this code
# 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