# example data
x <- c(
'P1:AAA|BwBwBwBw|CCCCCCC|CdCdCdCd',
'P2:Ap|AA|E|BhsBhs|Bw1Bw1|CCCCC',
'P3:A|Bt1Bt1Bt1|Bt2Bt2Bt2|Bt3|Cr|RRRRR',
'P4:AA|EEE|BhsBhsBhsBhs|BwBw|CCCCC',
'P5:AAAA|ACACACACAC|CCCCCCC|CdCdCd'
)
s <- quickSPC(x)
# change horizon depth names
# ensure that plotSPC() -> addBracket() can find them
horizonDepths(s) <- c('tt', 'bb')
# expression defines a single reference horizon in most profiles
.ex <- grepl('Bt3|Bw', s$name)
# encode for thematic profile sketches
s$e <- factor(as.character(.ex), levels = c('FALSE', 'TRUE'), labels = c('Horizons', 'Reference'))
# get horizon row indices to horizons above reference
a <- hzAbove(s, .ex, SPC = FALSE, simplify = TRUE)
# create bracket data.frame
b <- depths(s, hzID = FALSE)[a, ]
# add labels
b$label <- c('S')
op <- par(no.readonly = TRUE)
par(mar = c(0, 0, 3, 2), mfcol = c(1, 2))
# sketches
plotSPC(
s, color = 'e', col.label = 'Original', col.palette = c('grey', 'royalblue'),
name = 'name', name.style = 'center-center', cex.names = 0.75,
max.depth = 180
)
# plot individual brackets, no labels
addBracket(
b,
agg = FALSE, labcol = 'label',
offset = -0.35, col = 'black', tick.length = 0.04, lwd = 1
)
# sketches
plotSPC(
s, color = 'e', col.label = 'Aggregate', col.palette = c('grey', 'royalblue'),
name = 'name', name.style = 'center-center', cex.names = 0.75,
max.depth = 180
)
# aggregate multiple brackets into single depth span
# include first label from each group
addBracket(
b,
agg = TRUE, labcol = 'label',
offset = -0.35, col = 'firebrick', tick.length = 0.04, lwd = 2
)
par(op)
Run the code above in your browser using DataLab