diff --git a/articles/Introduction-to-SoilProfileCollection-Objects.html b/articles/Introduction-to-SoilProfileCollection-Objects.html index 5fb655b8..07ea4c58 100644 --- a/articles/Introduction-to-SoilProfileCollection-Objects.html +++ b/articles/Introduction-to-SoilProfileCollection-Objects.html @@ -258,7 +258,6 @@
#> [1] 0.1223958
Assignment of new data to existing or new attributes can proceed as follows.
-+# site-level (based on length of assigned data == number of profiles) sp4$elevation <- rnorm(n = length(sp4), mean = 1000, sd = 150) @@ -372,11 +371,11 @@
Horizon and Site Data# extraction of specific attributes by name sp4$clay # vector of clay content (horizon data)
-#> [1] 21 27 32 55 25 34 3 15 27 32 25 31 33 13 21 23 15 17 12 19 14 14 22 25 40 51 67 24 25 32
+sp4$elevation # vector of simulated elevation (site data)
-#> [1] 789.9935 1038.2976 634.4105 999.1643 1093.2329 1172.2617 726.7274 962.9012 963.3701 #> [10] 957.5942
+# unit-length value explicitly targeting site data site(sp4)$collection_id <- 1 @@ -394,7 +393,7 @@
. -Horizon and Site DataSoilProfileCollection
+# extract horizon data to data.frame h <- horizons(sp4) @@ -457,7 +456,7 @@
Diagnostic Horizons
+dh <- data.frame( id = 'colusa', kind = 'argillic', @@ -497,7 +496,7 @@
Root Restrictive FeaturesThe example data
sp4
does not describe the restrictive features, so we will simulate some at the bottom of each profile + 20cm. -+# get the depth of each profile rf.top <- profileApply(sp4, max) rf.bottom <- rf.top + 20 @@ -536,7 +535,7 @@
Object Metadata
SoilProfileCollection metadata can be extracted and set using the
-metadata()
andmetadata<-
methods.+-#> List of 6 @@ -546,7 +545,7 @@
Object Metadata#> $ aqp_hztexcl : chr "" #> $ depth_units : chr "cm" #> $ stringsAsFactors: logi FALSE
+-# alter the depth unit metadata attribute depth_units(sp4) <- 'inches' # units are really 'cm' @@ -567,7 +566,7 @@
Object Metadata#> $ describer : chr "DGM" #> $ date : Date[1:1], format: "2009-01-01" #> $ citation : chr "McGahan, D.G., Southard, R.J, Claassen, V.P. 2009. Plant-Available Calcium Varies Widely in Soils on Serpentini"| __truncated__
@@ -582,7 +581,7 @@+# fix depth units, set back to 'cm' depth_units(sp4) <- 'cm'
Spatial Data
+-# generate some fake coordinates as site level attributes sp4$x <- rnorm(n = length(sp4), mean = 354000, sd = 100) sp4$y <- rnorm(n = length(sp4), mean = 4109533, sd = 100) @@ -603,14 +602,14 @@
Spatial Data#> [8,] 354057.8 4109801 #> [9,] 354011.8 4109497 #> [10,] 353808.8 4109554
+# get/set spatial reference system using prj()<- prj(sp4) <- '+proj=utm +zone=11 +datum=NAD83' # return CRS information prj(sp4)
-#> [1] "+proj=utm +zone=11 +datum=NAD83"
+@@ -630,12 +629,12 @@# extract spatial data + site level attributes in new spatial object sp4.sp <- as(sp4, 'SpatialPointsDataFrame') sp4.sf <- as(sp4, 'sf')
Validity and Horizon Logichttps://github.com/ncss-tech/aqp/issues
-
checkSPC()
returns TRUE for a SoilProfileCollection that contains all slots defined in the class prototype.+checkSPC(sp4)
-
spc_in_sync()
is used as the validity method for the SoilProfileCollection, it determines if some reordering of the horizon data relative to the unique profile ID / site order has occurred.+spc_in_sync(sp4)
@@ -643,7 +642,7 @@#> nSites relativeOrder valid #> 1 TRUE TRUE TRUE
Validity and Horizon Logic -
+z <- rebuildSPC(sp4)
checkHzDepthLogic()
has the ability to perform logical tests on whole profiles or individual horizons. Four different tests are @@ -654,7 +653,7 @@Validity and Horizon Logic
missing (
NA
) top or bottom depth- gap or overlap between adjacent horizons
+checkHzDepthLogic(sp4)
-#> id valid depthLogic sameDepth missingDepth overlapOrGap #> 1 colusa TRUE FALSE FALSE FALSE FALSE @@ -667,7 +666,7 @@
Validity and Horizon Logic#> 8 shasta TRUE FALSE FALSE FALSE FALSE #> 9 shasta-trinity TRUE FALSE FALSE FALSE FALSE #> 10 tehama TRUE FALSE FALSE FALSE FALSE
+checkHzDepthLogic(sp4, byhz = TRUE)
#> id top bottom valid hzID depthLogic sameDepth missingDepth overlapOrGap #> 1 colusa 0 3 TRUE 1 FALSE FALSE FALSE NA @@ -708,7 +707,7 @@
,Coerciondata.frame
list
andSpatialPointsDataFrame
(when spatial slot has been set up): -+# check our work by viewing the internal structure str(sp4) @@ -744,7 +743,7 @@
ProfilesUsing the i index, select one or more profiles by numeric index. An index greater than the number of profiles will return an empty
SoilProfileCollection
object. -+# explicit string matching idx <- which(sp4$group == 'A') @@ -758,7 +757,7 @@
Profilessp4[idx, ]
In an interactive session, it is often simpler to use
-subset()
directly:+@@ -769,7 +768,7 @@subset(sp4, group == 'A') subset(sp4, elevation < 1000) subset(sp4, grepl('shasta', id, ignore.case = TRUE))
Horizons by Index
+sp4[, 2]
@@ -779,7 +778,7 @@@@ -794,7 +793,7 @@Horizons by Keyword
+sp4[, , .FIRST] sp4[, , .LAST]
Splitting, Dupli
SoilProfileCollection
. Manually subset the example data into 3 pieces, compile into a list, and thencombine
back together. -+# subset data into chunks s1 <- sp4[1:2, ] s2 <- sp4[4, ] @@ -809,7 +808,7 @@
Splitting, Dupli with different internal structure. The final object will contain the all site and horizon columns from the inputs, possibly creating sparse tables. IDs and horizon depth names are taken from the first object. -
+# sample data as data.frame objects data(sp1) data(sp3) @@ -854,7 +853,7 @@
isSplittingcombine()
split()
: subsets of theSoilProfileCollection
are split into list elements, each containing a newSoilProfileCollection
. -+# continuing from above # split subsets of x into a list of SoilProfileCollection objects using site-level attribute 'g' res <- split(x, 'g') @@ -866,17 +865,16 @@
Duplication
+ -#> [1] 0.5067568
Selecting Unique Profiles
-+-# an example soil profile x <- data.frame( id = 'A', @@ -908,19 +906,16 @@
Selecting Unique Profiles name.style = 'center-center', width = 0.15)
-#> [1] 0.03216912
+-# "uniqueness" is a function of variables selected to consider plotSPC(unique(x.sim, vars = c('top', 'bottom')), name.style = 'center-center')
-#> [1] 0.1617973
@@ -954,39 +949,39 @@Making AdjustmentsexplainPlotSPC() function is helpful for adjusting some of the more obscure arguments to
plotSPC()
.A basic plot with debugging information overlaid:
-+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name')
Make sketches wider:
-+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', width = 0.3)
Move soil surface at 0cm “down” 5cm:
-+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', y.offset = 5)
Move soil surface at 0cm “up” 10cm; useful for sketches of shallow profiles:
-+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', y.offset = -10)
Scale depths by 50%:
-+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', scaling.factor = 0.5)
A graphical explanation of how profiles are re-arranged via
-plot.order
argument:+par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', plot.order = length(sp4):1)
Leave room for an additional 2 profile sketches:
-+@@ -1009,30 +1004,27 @@par(mar = c(4, 3, 2, 2)) explainPlotSPC(sp4, name = 'name', n = length(sp4) + 2)
Small SoilProfileCollections
+data(osd) x <- osd
Using 5x6 inch output device:
-+ -#> [1] 0.2330044
Using 7x6 inch output device, slight adjustments to
-width
usually required:+-# set margins and turn off clipping par(mar = c(0, 2, 0, 4), xpd = NA) plotSPC(x[1:2, ], cex.names = 1, width = 0.25)
#> [1] 0.3259698
Using 8x6 inch output device, slight adjustments to are usually required:
-@@ -1040,7 +1032,7 @@Horizon Depth Labeling
Horizon depths can be labeled for each profile as an alternative to a single depth axis.
-+-par(mar = c(0, 0, 1, 1)) plotSPC( x, @@ -1052,7 +1044,6 @@
Horizon Depth Labeling hz.depths.offset = 0.08 )
#> [1] 0.3191774
As of aqp version 1.41, it is possible to “fix” overlapping horizon depth labels with the new
fixLabelCollisions
argument. This approach to labeling depths works best when moving horizon designations @@ -1069,7 +1060,7 @@Relative Horizontal Positioningplot.order but be careful:
relative.pos
must be specified in the final ordering of profiles. See?plotSPC
for details. -+@@ -1077,7 +1068,7 @@par(mar = c(4, 3, 2, 2)) pos <- jitter(1:length(sp4)) explainPlotSPC(sp4, name = 'name', relative.pos = pos)
Relative Horizontal PositioningRelative positioning works well when the vector of positions is close to the default spacing along an integer sequence, but not when positions are closer than the width of a profile sketch. -
+@@ -1089,7 +1080,7 @@par(mar = c(4, 3, 2, 2)) pos <- c(1, 1.2, 3, 4, 5, 5.2, 7, 8, 9, 10) explainPlotSPC(sp4, name = 'name', relative.pos = pos)
Relative Horizontal Positioningset.seed(). -
+@@ -1097,7 +1088,7 @@par(mar = c(4, 3, 2, 2)) new.pos <- fixOverlap(pos) explainPlotSPC(sp4, name = 'name', relative.pos = new.pos)
Relative Horizontal PositioningThere are several parameters available for optimizing horizontal position in the presence of overlap. See
?fixOverlap
for details and further examples. -+@@ -1110,16 +1101,15 @@par(mar = c(4, 3, 2, 2)) new.pos <- fixOverlap(pos, thresh = 0.7) explainPlotSPC(sp4, name = 'name', relative.pos = new.pos)
Thematic Sketches
+-par(mar = c(0, 0, 3, 0)) plotSPC(sp4, name = 'name', color = 'clay', col.label = 'Clay Content (%)')
#> [1] 0.4882812
Use a different set of colors:
-+-par(mar = c(0, 0, 3, 0)) plotSPC( sp4, @@ -1129,11 +1119,10 @@
Thematic Sketches= 'Clay Content (%)' )
#> [1] 0.4882812
Categorical properties can also be used to make a thematic sketch. Colors are interpolated when there are more classes than colors provided by
-col.palette
:+-par(mar = c(0, 0, 3, 0)) plotSPC( sp4, @@ -1143,10 +1132,9 @@
Thematic Sketches= 'Original Horizon Name' )
#> [1] 0.4882812
Try with generalized horizon labels:
-+-par(mar = c(0, 0, 3, 0)) # generalize horizon names into 3 groups @@ -1160,21 +1148,19 @@
Thematic Sketches= 'Generalized Horizon Name' )
#> [1] 0.4882812
Horizon-level attributes that represent a volume fraction (e.g. coarse-fragment percentage) can be added to an existing figure. See
-?addVolumeFraction
for adding layers to an existing plot based on these attributes.@@ -1185,7 +1171,7 @@+-par(mar = c(0, 0, 3, 0)) # convert coarse rock fragment proportion to percentage sp4$frag_pct <- sp4$CF * 100 # label horizons with fragment percent -plotSPC(sp4, name = 'frag_pct', color = 'frag_pct')
-#> [1] 0.4882812
-# symbolize volume fraction data +plotSPC(sp4, name = 'frag_pct', color = 'frag_pct') + +# symbolize volume fraction data addVolumeFraction(sp4, colname = 'frag_pct')
Depth IntervalsdepthOf() function. See ?depthOf for more details. -
+-# extract top/bottom depths associated with all A horizons tops <- minDepthOf(sp4, pattern = '^A', hzdesgn = 'name', top = TRUE) bottoms <- maxDepthOf(sp4, pattern = '^A', hzdesgn = 'name', top = FALSE) @@ -1208,21 +1194,19 @@
Depth Intervals#> 8 shasta 0 3 #> 9 shasta-trinity 0 12 #> 10 tehama 0 3
+ --#> [1] 0.4882812
-# annotate A horizon depth interval with brackets +plotSPC(sp4) + +# annotate A horizon depth interval with brackets addBracket(a, col = 'red', offset = -0.4)
Add labels:
-+ --#> [1] 0.4882812
-# addBracket() looks for a column `label`; add a ID for each bracket +plotSPC(sp4, name = 'name') + +# addBracket() looks for a column `label`; add a ID for each bracket a$label <- site(sp4)$id # note that depth brackets "knows which profiles to use" via profile ID @@ -1236,38 +1220,30 @@
Depth Intervals
It is possible to arrange profile sketches by site-level grouping variable:
-+-par(mar = c(0, 0, 0, 0)) -groupedProfilePlot(sp4, groups = 'group')
-#> [1] 0.4882812
+groupedProfilePlot(sp4, groups = 'group') +addBracket(a, col = 'red', offset = -0.4)-addBracket(a, col = 'red', offset = -0.4)
There need not be brackets for all profiles in a collection:
-+-par(mar = c(0, 0, 0, 0)) a.sub <- a[1:4,] -groupedProfilePlot(sp4, groups = 'group')
-#> [1] 0.4882812
+groupedProfilePlot(sp4, groups = 'group') +addBracket(a.sub, col = 'red', offset = -0.4)-addBracket(a.sub, col = 'red', offset = -0.4)
When bottom depths are missing an arrow is used:
-+-a$bottom <- NA par(mar = c(0, 0, 0, 0)) -groupedProfilePlot(sp4, groups = 'group')
-#> [1] 0.4882812
+groupedProfilePlot(sp4, groups = 'group') +addBracket(a, col = 'red', offset = -0.4)-addBracket(a, col = 'red', offset = -0.4)
Manually define bottom depth:
-+-par(mar = c(0, 0, 0, 0)) -groupedProfilePlot(sp4, groups = 'group')
-#> [1] 0.4882812
-addBracket( +groupedProfilePlot(sp4, groups = 'group') +addBracket( a, col = 'red', label.cex = 0.75, @@ -1276,12 +1252,11 @@
Depth Intervals)
Further customization of brackets:
-+ --#> [1] 0.4882812
-# copy root-restricting features +plotSPC(sp4, max.depth = 75) + +# copy root-restricting features a <- restrictions(sp4) # add a label: restrictive feature 'kind' @@ -1314,7 +1289,7 @@
SVG Output for Use in Page Layo with most software titles. WMF output is compatible with MS Office tools and can be written with the
win.metafile()
function. -+# library(svglite) # svglite(filename = 'e:/temp/fig.svg', width = 7, height = 6, pointsize = 12) # @@ -1334,7 +1309,7 @@
Iterating Over Profiles in a Co for each profile in the collection, typically returning a single value per profile. In this case, the ordering of the results would match the ordering of values in the site level attribute table. -
+# max() returns the depth of a soil profile sp4$soil.depth <- profileApply(sp4, FUN = max) @@ -1354,7 +1329,7 @@
Iterating Over Profiles in a Co to create new horizon-level attributes. For example, the change in clay content by horizon depth (
delta.clay
, below) could be calculated as: -+# save as horizon-level attribute sp4$delta.clay <- profileApply(sp4, FUN = function(i) c(NA, diff(i$clay))) @@ -1377,7 +1352,7 @@
Iterating Over Profiles in a Co custom function can be combined into a single
SoilProfileCollection
object viacombine()
. -+# compute hz-thickness weighted mean exchangeable-Ca:Mg wt.mean.ca.mg <- function(i) { # use horizon thickness as a weight @@ -1394,7 +1369,7 @@
Iterating Over Profiles in a Co
In this case profiles are ordered based on the horizon-thickness weighted mean, exchangeable Ca:Mg values. Horizons are colored by exchangeable Ca:Mg values.
-+-# plot the data using our new order based on Ca:Mg weighted average # the result is an index of rank new.order <- order(sp4$wt.mean.ca.to.mg) @@ -1403,10 +1378,9 @@
Iterating Over Profiles in a Co plotSPC(sp4, name = 'name', color = 'ex_Ca_to_Mg', - plot.order = new.order)
-#> [1] 0.4882812
@@ -1421,7 +1395,7 @@-# add an axis labeled with the sorting criteria + plot.order = new.order) + +# add an axis labeled with the sorting criteria axis(1, at = 1:length(sp4), labels = round(sp4$wt.mean.ca.to.mg, 3), cex.axis = 0.75) mtext(1, line = 2.25, text = 'Horizon Thickness Weighted Mean Ex. Ca:Mg', cex = 0.75)
Slicing Horizons:
dice()
dice() function. The slicing structure and variables of interest are defined via formula notation: -+# slice select horizon-level attributes seq ~ var.1 + var.2 + var.3 + ... # slice all horizon-level attributes @@ -1435,7 +1409,7 @@
Slicing Horizons:
dice()
+-# resample to 1cm slices s <- dice(sp4, fm = 0:15 ~ sand + silt + clay + name + ex_Ca_to_Mg) @@ -1444,15 +1418,14 @@
Slicing Horizons:
dice()
#> [1] "SoilProfileCollection" #> attr(,"package") #> [1] "aqp"+-# plot sliced data par(mar = c(0, 0, 3, 0)) # tighten figure margins plotSPC(s, color = 'ex_Ca_to_Mg')
#> [1] 0.4882812
Once soil profile data have been sliced, it is simple to extract “chunks” of data by depth interval via
-[
-subsetting:+# slice from 0 to max depth in the collection s <- dice(sp4, fm= 0:max(sp4) ~ sand + silt + clay + name + ex_Ca_to_Mg) @@ -1469,43 +1442,39 @@
Slicing Horizons:
dice()
Ragged Extraction:glom()
Select all horizons that overlap the interval of 5-15cm:
-+-# truncate to the interval 5-15cm clods <- glom(sp4, z1 = 5, z2 = 15) # plot outlines of original profiles par(mar = c(0, 0, 3, 1.5)) -plotSPC(sp4, color = NA, name = NA, print.id = FALSE, depth.axis = FALSE, lwd = 0.5)
-#> [1] 0.5073052
--# overlay glom() depth criteria +plotSPC(sp4, color = NA, name = NA, print.id = FALSE, depth.axis = FALSE, lwd = 0.5) + +# overlay glom() depth criteria rect(xleft = 0.5, ybottom = 15, xright = length(sp4) + 0.5, ytop = 5, lty = 2) # add SoilProfileCollection with selected horizons plotSPC(clods, add = TRUE, cex.names = 0.6, name = 'name', color = 'ex_Ca_to_Mg', name.style = 'center-center')
#> [1] 0.5999729
Truncation:
trunc()
Truncate the SPC to the interval of 5-15cm:
-+-# truncate to the interval 5-15cm sp4.truncated <- trunc(sp4, 5, 15) # plot outlines of original profiles par(mar = c(0, 0, 3, 1.5)) -plotSPC(sp4, color = NA, name = NA, print.id = FALSE, lwd = 0.5)
-#> [1] 0.5073052
--# overlay truncation criteria +plotSPC(sp4, color = NA, name = NA, print.id = FALSE, lwd = 0.5) + +# overlay truncation criteria rect(xleft = 0.5, ybottom = 15, xright = length(sp4) + 0.5, ytop = 5, lty = 2) # add truncated SoilProfileCollection plotSPC(sp4.truncated, depth.axis = FALSE, add = TRUE, cex.names = 0.6, name = 'name', color = 'ex_Ca_to_Mg', name.style = 'center-center')
#> [1] 0.5999729
Change of Support @@ -1539,7 +1508,7 @@
Aggregation over “slabs”c(0, 5, 10, 50, 100)): data are aggregated over the depths spanning 0–5, 5–10, 10–50, 50–100 units -
+-# aggregate a couple of the horizon-level attributes, # across the entire collection, # from 0--10 cm @@ -1555,7 +1524,7 @@
Aggregation over “slabs”#> 1 sand 1 47.63 1 0 10 #> 2 silt 1 31.15 1 0 10 #> 3 clay 1 21.11 1 0 10
+-# again, this time within groups defined by a site-level attribute: slab( sp4, @@ -1571,7 +1540,7 @@
Aggregation over “slabs”#> 4 silt B 30.78 1 0 10 #> 5 clay A 20.30 1 0 10 #> 6 clay B 21.92 1 0 10
+-# again, this time over several depth ranges slab( sp4, @@ -1590,7 +1559,7 @@
Aggregation over “slabs”#> 7 clay 1 21.11000 1.0000000 0 10 #> 8 clay 1 28.10687 0.8733333 10 25 #> 9 clay 1 36.26966 0.5933333 25 40
+-# again, this time along 1-cm slices, computing quantiles agg <- slab(sp4, fm = ~ Mg + Ca + ex_Ca_to_Mg + CEC_7 + clay) @@ -1603,7 +1572,7 @@
Aggregation over “slabs”#> 4 Mg 1 6.195 13.175 21.05 25.050 30.73 1 3 4 #> 5 Mg 1 6.195 13.175 21.05 25.050 30.73 1 4 5 #> 6 Mg 1 6.195 13.175 21.05 26.250 31.72 1 5 6
+# plot median +/i bounds defined by the 25th and 75th percentiles # this is lattice graphics, syntax is a little rough xyplot(top ~ p.q50 | variable, data = agg, ylab = 'Depth', @@ -1624,7 +1593,7 @@
Aggregation over “slabs”
Depth-wise aggregation can be useful for visual evaluation of multivariate similarity among groups of profiles.
-+# processing the "napa" and tehama profiles idx <- which(profile_id(sp4) %in% c('napa', 'tehama')) napa.and.tehama <- slab(sp4[idx,], fm = ~ Mg + Ca + ex_Ca_to_Mg + CEC_7 + clay) @@ -1658,7 +1627,7 @@
Aggregation over “slabs”
The following example is based on a set of 9 randomly generated profiles, re-aligned to the Global Soil Map (GSM) standard depths.
-@@ -1778,7 +1739,7 @@+library(data.table) library(RColorBrewer) @@ -1699,7 +1668,7 @@
metric returned byAggregation over “slabs”A simple graphical comparison of the original and re-aligned soil profile data, after converting
slab()
result from long -> wide format with {data.table}dcast()
: -+-# reshape to wide format # this scales to > 1 aggregated variables d.gsm.pedons <- data.table::dcast( @@ -1718,14 +1687,10 @@
Aggregation over “slabs” # compare original and aggregated par(mar = c(1, 0, 3, 3), mfrow = c(2, 1)) -plotSPC(d, color = 'p1')
- -#> [1] 0.06138393
-#> [1] 0.06138393
+plotSPC(d, color = 'p1') +mtext('original depths', side = 2, line = -1.5) +plotSPC(d.gsm.pedons, color = 'p1') +mtext('GSM depths', side = 2, line = -1.5)-mtext('GSM depths', side = 2, line = -1.5)
Note that re-aligned data may not represent reality (and should therefore be used with caution) when the original soil depth is @@ -1733,7 +1698,7 @@
Aggregation over “slabs”contributing_fraction
slab()
can be useful for assessing how much real data were used to generate the new set of re-aligned data. -+-# reshape to wide format d.gsm.pedons.2 <- data.table::dcast( data.table(d.gsm), @@ -1746,10 +1711,8 @@
Aggregation over “slabs” # compare original and aggregated par(mar = c(1, 0, 3, 3), mfrow = c(2, 1)) -plotSPC(d.gsm.pedons, name = '', color = 'p1')
-#> [1] 0.06138393
--mtext('GSM depths', side = 2, line = -1.5) +plotSPC(d.gsm.pedons, name = '', color = 'p1') +mtext('GSM depths', side = 2, line = -1.5) plotSPC( d.gsm.pedons.2, @@ -1757,10 +1720,8 @@
Aggregation over “slabs” color = 'p1', col.label = 'Contributing Fraction', col.palette = RColorBrewer::brewer.pal(10, 'Spectral') -)
-#> [1] 0.06138393
+) +mtext('GSM depths', side = 2, line = -1.5)-mtext('GSM depths', side = 2, line = -1.5)
Pair-Wise Dissimilarity:
NCSP()See the function manual page and this paper for details. -
+-library(cluster) library(sharpshootR) @@ -1805,7 +1766,7 @@
Pair-Wise Dissimilarity:
NCSP()#> shasta 17.2 13.6 8.7 17.6 17.6 34.8 23.3 #> shasta-trinity 6.4 16.9 22.3 9.6 17.0 30.9 28.3 23.3 #> tehama 30.1 23.9 29.2 28.6 20.8 9.0 15.3 32.7 29.2
-+-# visualize dissimilarity matrix via divisive hierarchical clustering d.diana <- diana(d) @@ -1825,7 +1786,6 @@
Pair-Wise Dissimilarity:
NCSP() depth.axis = FALSE )
#> [1] 0.5322917
Some additional examples can be found in:
#> [1] 1.052334
Subgroup level classification (encoded as an un-ordered factor) will be used as a site-level attribute for computing pair-wise distances. Quickly review the grouping structure with
-groupedProfilePlot()
.+-# encode as a factor for distance calculation z$subgroup <- factor(z$subgroup) par(mar = c(0, 0, 1, 1)) groupedProfilePlot(z, groups = 'subgroup', group.name.offset = -10, break.style = 'arrow', group.line.lty = 1, group.line.lwd = 1)
#> [1] 1.052334
Horizon designation, grouped into “generalized horizon labels” will be used as the horizon-level attribute for computing pair-wise distances. REGEX pattern matching is used to apply @@ -190,7 +188,7 @@
A Simple Example -
+-# assign GHL z$genhz <- generalize.hz( z$hzname, new = c('A', 'E', 'Bt', 'C'), @@ -201,13 +199,12 @@
A Simple Examplepar(mar = c(0, 0, 3, 1)) groupedProfilePlot(z, groups = 'subgroup', group.name.offset = -10, break.style = 'arrow', group.line.lty = 1, group.line.lwd = 1, color = 'genhz')
#> [1] 1.052334
Define weights and compute separately horizon and site level distance matrices. In this case, the site-level distances are give double the weight as the horizon-level distances. See the manual pages (
-?NCSP
and?compareSites
) for additional arguments that can be used to further customize the comparison.+# horizon-level distance matrix weight w1 <- 1 # perform NCSP using only the GHL (ordered factors) to a depth of 185cm @@ -229,16 +226,15 @@
A Simple Example -
+-# divisive hierarchical clustering h <- as.hclust(diana(D)) # hang soil profile sketches from resulting dendrogram par(mar = c(1, 0, 0, 1)) -plotProfileDendrogram(z, clust = h, scaling.factor = 0.0075, y.offset = 0.15, width = 0.33, color = 'genhz', name = NA)
-#> [1] 1.052334
-# annotate dendorgram with subgroup classification +plotProfileDendrogram(z, clust = h, scaling.factor = 0.0075, y.offset = 0.15, width = 0.33, color = 'genhz', name = NA) + +# annotate dendorgram with subgroup classification # this handy function provided by the {ape} package tiplabels(pch = 15, col = c(2, 3)[z$subgroup], cex = 1.5, offset = 0.05) diff --git a/articles/label-placement.html b/articles/label-placement.html index 47b2608a..9f70fd2d 100644 --- a/articles/label-placement.html +++ b/articles/label-placement.html @@ -118,7 +118,6 @@
Introduction -