sp4 {aqp}R Documentation

Soil Chemical Data from Serpentinitic Soils of California

Description

Soil Chemical Data from Serpentinitic Soils of California

Usage

data(sp4)

Format

A data frame with 30 observations on the following 13 variables.

id

site name

name

horizon designation

top

horizon top boundary in cm

bottom

horizon bottom boundary in cm

K

exchangeable K in c mol/kg

Mg

exchangeable Mg in cmol/kg

Ca

exchangeable Ca in cmol/kg

CEC_7

cation exchange capacity (NH4OAc at pH 7)

ex_Ca_to_Mg

extractable Ca:Mg ratio

sand

sand content by weight percentage

silt

silt content by weight percentage

clay

clay content by weight percentage

CF

>2mm fraction by volume percentage

Details

Selected soil physical and chemical data from (McGahan et al., 2009).

Source

https://www.soils.org/publications/sssaj/articles/73/6/2087

References

McGahan, D.G., Southard, R.J, Claassen, V.P. 2009. Plant-Available Calcium Varies Widely in Soils on Serpentinite Landscapes. Soil Sci. Soc. Am. J. 73: 2087-2095.

Examples

# setup environment
library(aqp)

# load sample data set, a simple data.frame object with horizon-level data from 10 profiles
data(sp4)
str(sp4)
## 'data.frame':    30 obs. of  13 variables:
##  $ id         : chr  "colusa" "colusa" "colusa" "colusa" ...
##  $ name       : chr  "A" "ABt" "Bt1" "Bt2" ...
##  $ top        : int  0 3 8 30 0 9 0 4 13 0 ...
##  $ bottom     : int  3 8 30 42 9 34 4 13 40 6 ...
##  $ K          : num  0.3 0.2 0.1 0.1 0.2 0.3 0.2 0.6 0.8 0.4 ...
##  $ Mg         : num  25.7 23.7 23.2 44.3 21.9 18.9 12.1 12.1 17.7 16.4 ...
##  $ Ca         : num  9 5.6 1.9 0.3 4.4 4.5 1.4 7 4.4 24.1 ...
##  $ CEC_7      : num  23 21.4 23.7 43 18.8 27.5 23.7 18 20 31.1 ...
##  $ ex_Ca_to_Mg: num  0.35 0.23 0.08 0.01 0.2 0.2 0.58 0.51 0.25 1.47 ...
##  $ sand       : int  46 42 40 27 54 49 43 36 27 43 ...
##  $ silt       : int  33 31 28 18 20 18 55 49 45 42 ...
##  $ clay       : int  21 27 32 55 25 34 3 15 27 15 ...
##  $ CF         : num  0.12 0.27 0.27 0.16 0.55 0.84 0.5 0.75 0.67 0.02 ...
# optionally read about it...
# ?sp4

# upgrade to SoilProfileCollection
# 'id' is the name of the column containing the profile ID
# 'top' is the name of the column containing horizon upper boundaries
# 'bottom' is the name of the column containing horizon lower boundaries
depths(sp4) <- id ~ top + bottom

# check it out
class(sp4) # class name
## [1] "SoilProfileCollection"
## attr(,"package")
## [1] "aqp"
str(sp4) # internal structure
## Formal class 'SoilProfileCollection' [package "aqp"] with 7 slots
##   ..@ idcol     : chr "id"
##   ..@ depthcols : chr [1:2] "top" "bottom"
##   ..@ metadata  :'data.frame':   1 obs. of  1 variable:
##   .. ..$ depth_units: chr "cm"
##   ..@ horizons  :'data.frame':   30 obs. of  13 variables:
##   .. ..$ id         : chr [1:30] "colusa" "colusa" "colusa" "colusa" ...
##   .. ..$ name       : chr [1:30] "A" "ABt" "Bt1" "Bt2" ...
##   .. ..$ top        : int [1:30] 0 3 8 30 0 9 0 4 13 0 ...
##   .. ..$ bottom     : int [1:30] 3 8 30 42 9 34 4 13 40 3 ...
##   .. ..$ K          : num [1:30] 0.3 0.2 0.1 0.1 0.2 0.3 0.2 0.6 0.8 0.6 ...
##   .. ..$ Mg         : num [1:30] 25.7 23.7 23.2 44.3 21.9 18.9 12.1 12.1 17.7 28.3 ...
##   .. ..$ Ca         : num [1:30] 9 5.6 1.9 0.3 4.4 4.5 1.4 7 4.4 5.8 ...
##   .. ..$ CEC_7      : num [1:30] 23 21.4 23.7 43 18.8 27.5 23.7 18 20 29.3 ...
##   .. ..$ ex_Ca_to_Mg: num [1:30] 0.35 0.23 0.08 0.01 0.2 0.2 0.58 0.51 0.25 0.2 ...
##   .. ..$ sand       : int [1:30] 46 42 40 27 54 49 43 36 27 42 ...
##   .. ..$ silt       : int [1:30] 33 31 28 18 20 18 55 49 45 26 ...
##   .. ..$ clay       : int [1:30] 21 27 32 55 25 34 3 15 27 32 ...
##   .. ..$ CF         : num [1:30] 0.12 0.27 0.27 0.16 0.55 0.84 0.5 0.75 0.67 0.25 ...
##   ..@ site      :'data.frame':   10 obs. of  1 variable:
##   .. ..$ id: chr [1:10] "colusa" "glenn" "kings" "mariposa" ...
##   ..@ sp        :Formal class 'SpatialPoints' [package "sp"] with 3 slots
##   .. .. ..@ coords     : num [1, 1] 0
##   .. .. ..@ bbox       : logi [1, 1] NA
##   .. .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
##   .. .. .. .. ..@ projargs: chr NA
##   ..@ diagnostic:'data.frame':   0 obs. of  0 variables
# inspect object properties
idname(sp4) # self-explanitory
## [1] "id"
horizonDepths(sp4) # self-explanitory
## [1] "top"    "bottom"
# you can change these:
depth_units(sp4) # defaults to 'cm'
## [1] "cm"
metadata(sp4) # not much to start with
## Error in metadata(sp4): no slot of name "history" for this object of class "SoilProfileCollection"
# alter the depth unit metadata
depth_units(sp4) <- 'inches' # units are really 'cm'

# more generic interface for adjusting metadata
md <- metadata(sp4) # save original metadata
## Error in metadata(sp4): no slot of name "history" for this object of class "SoilProfileCollection"
# add columns
md$describer <- 'DGM'
## Error in md$describer <- "DGM": object 'md' not found
md$date <- as.Date('2009-01-01')
## Error in md$date <- as.Date("2009-01-01"): object 'md' not found
md$citation <- 'McGahan, D.G., Southard, R.J, Claassen, V.P. 
2009. Plant-Available Calcium Varies Widely in Soils 
on Serpentinite Landscapes. Soil Sci. Soc. Am. J. 73: 2087-2095.'
## Error in md$citation <- "McGahan, D.G., Southard, R.J, Claassen, V.P. \n2009. Plant-Available Calcium Varies Widely in Soils \non Serpentinite Landscapes. Soil Sci. Soc. Am. J. 73: 2087-2095.": object 'md' not found
# re-assign
metadata(sp4) <- md
## Error in eval(expr, envir, enclos): object 'md' not found
depth_units(sp4) <- 'cm' # fix depth units, back to 'cm'

# further inspection with common function overloads
length(sp4) # number of profiles in the collection
## [1] 10
nrow(sp4) # number of horizons in the collection
## [1] 30
names(sp4) # column names
##     horizons1     horizons2     horizons3     horizons4     horizons5 
##          "id"        "name"         "top"      "bottom"           "K" 
##     horizons6     horizons7     horizons8     horizons9    horizons10 
##          "Mg"          "Ca"       "CEC_7" "ex_Ca_to_Mg"        "sand" 
##    horizons11    horizons12    horizons13 
##        "silt"        "clay"          "CF"
min(sp4) # shallowest profile depth in collection
## [1] 16
max(sp4) # deepest profile depth in collection
## [1] 49
# extraction of soil profile components
profile_id(sp4) # vector of profile IDs
##  [1] "colusa"         "glenn"          "kings"          "mariposa"      
##  [5] "mendocino"      "napa"           "san benito"     "shasta"        
##  [9] "shasta-trinity" "tehama"
horizons(sp4) # horizon data
##                id name top bottom   K   Mg   Ca CEC_7 ex_Ca_to_Mg sand
## 1          colusa    A   0      3 0.3 25.7  9.0  23.0        0.35   46
## 2          colusa  ABt   3      8 0.2 23.7  5.6  21.4        0.23   42
## 3          colusa  Bt1   8     30 0.1 23.2  1.9  23.7        0.08   40
## 4          colusa  Bt2  30     42 0.1 44.3  0.3  43.0        0.01   27
## 5           glenn    A   0      9 0.2 21.9  4.4  18.8        0.20   54
## 6           glenn   Bt   9     34 0.3 18.9  4.5  27.5        0.20   49
## 7           kings    A   0      4 0.2 12.1  1.4  23.7        0.58   43
## 8           kings  Bt1   4     13 0.6 12.1  7.0  18.0        0.51   36
## 9           kings  Bt2  13     40 0.8 17.7  4.4  20.0        0.25   27
## 19       mariposa    A   0      3 0.6 28.3  5.8  29.3        0.20   42
## 20       mariposa  Bt1   3     14 0.4 33.7  6.2  27.9        0.18   41
## 21       mariposa  Bt2  14     34 0.3 44.3  6.2  34.1        0.14   36
## 22       mariposa  Bt3  34     49 0.1 78.2  4.4  43.6        0.06   36
## 23      mendocino    A   0      2 0.5 12.8  2.2  19.3        0.18   57
## 24      mendocino  Bt1   2      8 0.2 27.1  3.4  19.8        0.13   51
## 25      mendocino  Bt2   8     30 0.2 30.5  3.7  22.9        0.12   51
## 10           napa    A   0      6 0.4 16.4 24.1  31.1        1.47   43
## 11           napa   Bt   6     20 0.1 16.2 21.5  27.9        1.32   54
## 12     san benito    A   0      8  NA  3.0  0.7   3.1        0.24   80
## 13     san benito   Bt   8     20 0.0  0.1  5.6   5.6        0.11   74
## 14         shasta    A   0      3 0.3  9.7  3.5  13.2        0.36   37
## 15         shasta   Bt   3     40 0.2 10.1  2.0  12.2        0.20   39
## 26 shasta-trinity   A1   0      2 0.2 18.8  6.6  23.0        0.35   34
## 27 shasta-trinity   A2   2      5 0.2 25.5  4.1  21.5        0.16   33
## 28 shasta-trinity   AB   5     12 0.3 29.3  3.5  29.6        0.12   24
## 29 shasta-trinity  Bt1  12     23 0.2 30.3  1.5  26.5        0.05   20
## 30 shasta-trinity  Bt2  23     40 0.1 64.9  0.8  48.7        0.01   11
## 16         tehama    A   0      3 0.4 12.4 16.3  40.2        1.31   57
## 17         tehama  Bt1   3      7 0.5 20.2 16.5  32.7        0.82   55
## 18         tehama  Bt2   7     16 0.2 27.7 13.7  30.0        0.50   51
##    silt clay   CF
## 1    33   21 0.12
## 2    31   27 0.27
## 3    28   32 0.27
## 4    18   55 0.16
## 5    20   25 0.55
## 6    18   34 0.84
## 7    55    3 0.50
## 8    49   15 0.75
## 9    45   27 0.67
## 19   26   32 0.25
## 20   34   25 0.38
## 21   33   31 0.71
## 22   31   33 0.67
## 23   30   13 0.16
## 24   28   21 0.14
## 25   26   23 0.80
## 10   42   15 0.02
## 11   29   17 0.07
## 12    8   12 0.43
## 13    7   19 0.60
## 14   49   14 0.78
## 15   46   14 0.88
## 26   44   22 0.17
## 27   42   25 0.13
## 28   36   40 0.09
## 29   29   51 0.05
## 30   22   67 0.05
## 16   19   24 0.43
## 17   20   25 0.10
## 18   17   32 0.34
# extraction of specific horizon attributes
sp4$clay # vector of clay content
##  [1] 21 27 32 55 25 34  3 15 27 32 25 31 33 13 21 23 15 17 12 19 14 14 22
## [24] 25 40 51 67 24 25 32
# subsetting SoilProfileCollection objects
sp4[1, ] # first profile in the collection
## Object of class SoilProfileCollection
## Number of profiles: 1
## 
## Horizon attributes:
##       id name top bottom   K   Mg  Ca CEC_7 ex_Ca_to_Mg sand silt clay
## 1 colusa    A   0      3 0.3 25.7 9.0  23.0        0.35   46   33   21
## 2 colusa  ABt   3      8 0.2 23.7 5.6  21.4        0.23   42   31   27
## 3 colusa  Bt1   8     30 0.1 23.2 1.9  23.7        0.08   40   28   32
## 4 colusa  Bt2  30     42 0.1 44.3 0.3  43.0        0.01   27   18   55
##     CF
## 1 0.12
## 2 0.27
## 3 0.27
## 4 0.16
## 
## Sampling site attributes:
##       id
## 1 colusa
## 
## Spatial Data:
##      [,1]
## [1,]   NA
## [1] NA
sp4[, 1] # first horizon from each profile
## Object of class SoilProfileCollection
## Number of profiles: 10
## Depth range: 2-9 cm
## 
## Horizon attributes:
##          id name top bottom   K   Mg   Ca CEC_7 ex_Ca_to_Mg sand silt clay
## 1    colusa    A   0      3 0.3 25.7  9.0  23.0        0.35   46   33   21
## 2     glenn    A   0      9 0.2 21.9  4.4  18.8        0.20   54   20   25
## 3     kings    A   0      4 0.2 12.1  1.4  23.7        0.58   43   55    3
## 4  mariposa    A   0      3 0.6 28.3  5.8  29.3        0.20   42   26   32
## 5 mendocino    A   0      2 0.5 12.8  2.2  19.3        0.18   57   30   13
## 6      napa    A   0      6 0.4 16.4 24.1  31.1        1.47   43   42   15
##     CF
## 1 0.12
## 2 0.55
## 3 0.50
## 4 0.25
## 5 0.16
## 6 0.02
## 
## Sampling site attributes:
##          id
## 1    colusa
## 2     glenn
## 3     kings
## 4  mariposa
## 5 mendocino
## 6      napa
# basic plot method, highly customizable: see manual page ?plotSPC
plot(sp4)
# inspect plotting area, very simple to overlay graphical elements
abline(v=1:length(sp4), lty=3, col='blue')
# profiles are centered at integers, from 1 to length(obj)
axis(1, line=-1.5, at=1:10, cex.axis=0.75, font=4, col='blue', lwd=2)
# y-axis is based on profile depths
axis(2, line=-1, at=pretty(1:max(sp4)), cex.axis=0.75, font=4, las=1, col='blue', lwd=2)

plot of chunk unnamed-chunk-1

# symbolize soil properties via color
par(mar=c(0,0,4,0))
plot(sp4, color='clay')

plot of chunk unnamed-chunk-1

plot(sp4, color='CF')

plot of chunk unnamed-chunk-1

# apply a function to each profile, returning a single value per profile,
# in the same order as profile_id(sp4)
soil.depths <- profileApply(sp4, max) # recall that max() gives the depth of a soil profile

# check that the order is correct
all.equal(names(soil.depths), profile_id(sp4))
## [1] TRUE
# a vector of values that is the same length as the number of profiles
# can be stored into site-level data
sp4$depth <- soil.depths
# check: looks good
max(sp4[1, ]) == sp4$depth[1]
## [1] TRUE
# extract site-level data 
site(sp4) # as a data.frame
##                id depth
## 1          colusa    42
## 2           glenn    34
## 3           kings    40
## 4        mariposa    49
## 5       mendocino    30
## 6            napa    20
## 7      san benito    20
## 8          shasta    40
## 9  shasta-trinity    40
## 10         tehama    16
sp4$depth # specific columns as a vector
##  [1] 42 34 40 49 30 20 20 40 40 16
# use site-level data to alter plotting order
new.order <- order(sp4$depth) # the result is an index of rank
par(mar=c(0,0,0,0))
plot(sp4, plot.order=new.order)

plot of chunk unnamed-chunk-1

# deconstruct SoilProfileCollection into a data.frame, with horizon+site data
as(sp4, 'data.frame')
##                id name top bottom   K   Mg   Ca CEC_7 ex_Ca_to_Mg sand
## 1          colusa    A   0      3 0.3 25.7  9.0  23.0        0.35   46
## 2          colusa  ABt   3      8 0.2 23.7  5.6  21.4        0.23   42
## 3          colusa  Bt1   8     30 0.1 23.2  1.9  23.7        0.08   40
## 4          colusa  Bt2  30     42 0.1 44.3  0.3  43.0        0.01   27
## 5           glenn    A   0      9 0.2 21.9  4.4  18.8        0.20   54
## 6           glenn   Bt   9     34 0.3 18.9  4.5  27.5        0.20   49
## 7           kings    A   0      4 0.2 12.1  1.4  23.7        0.58   43
## 8           kings  Bt1   4     13 0.6 12.1  7.0  18.0        0.51   36
## 9           kings  Bt2  13     40 0.8 17.7  4.4  20.0        0.25   27
## 10       mariposa    A   0      3 0.6 28.3  5.8  29.3        0.20   42
## 11       mariposa  Bt1   3     14 0.4 33.7  6.2  27.9        0.18   41
## 12       mariposa  Bt2  14     34 0.3 44.3  6.2  34.1        0.14   36
## 13       mariposa  Bt3  34     49 0.1 78.2  4.4  43.6        0.06   36
## 14      mendocino    A   0      2 0.5 12.8  2.2  19.3        0.18   57
## 15      mendocino  Bt1   2      8 0.2 27.1  3.4  19.8        0.13   51
## 16      mendocino  Bt2   8     30 0.2 30.5  3.7  22.9        0.12   51
## 17           napa    A   0      6 0.4 16.4 24.1  31.1        1.47   43
## 18           napa   Bt   6     20 0.1 16.2 21.5  27.9        1.32   54
## 19     san benito    A   0      8  NA  3.0  0.7   3.1        0.24   80
## 20     san benito   Bt   8     20 0.0  0.1  5.6   5.6        0.11   74
## 21         shasta    A   0      3 0.3  9.7  3.5  13.2        0.36   37
## 22         shasta   Bt   3     40 0.2 10.1  2.0  12.2        0.20   39
## 23 shasta-trinity   A1   0      2 0.2 18.8  6.6  23.0        0.35   34
## 24 shasta-trinity   A2   2      5 0.2 25.5  4.1  21.5        0.16   33
## 25 shasta-trinity   AB   5     12 0.3 29.3  3.5  29.6        0.12   24
## 26 shasta-trinity  Bt1  12     23 0.2 30.3  1.5  26.5        0.05   20
## 27 shasta-trinity  Bt2  23     40 0.1 64.9  0.8  48.7        0.01   11
## 28         tehama    A   0      3 0.4 12.4 16.3  40.2        1.31   57
## 29         tehama  Bt1   3      7 0.5 20.2 16.5  32.7        0.82   55
## 30         tehama  Bt2   7     16 0.2 27.7 13.7  30.0        0.50   51
##    silt clay   CF depth
## 1    33   21 0.12    42
## 2    31   27 0.27    42
## 3    28   32 0.27    42
## 4    18   55 0.16    42
## 5    20   25 0.55    34
## 6    18   34 0.84    34
## 7    55    3 0.50    40
## 8    49   15 0.75    40
## 9    45   27 0.67    40
## 10   26   32 0.25    49
## 11   34   25 0.38    49
## 12   33   31 0.71    49
## 13   31   33 0.67    49
## 14   30   13 0.16    30
## 15   28   21 0.14    30
## 16   26   23 0.80    30
## 17   42   15 0.02    20
## 18   29   17 0.07    20
## 19    8   12 0.43    20
## 20    7   19 0.60    20
## 21   49   14 0.78    40
## 22   46   14 0.88    40
## 23   44   22 0.17    40
## 24   42   25 0.13    40
## 25   36   40 0.09    40
## 26   29   51 0.05    40
## 27   22   67 0.05    40
## 28   19   24 0.43    16
## 29   20   25 0.10    16
## 30   17   32 0.34    16

[Package aqp version 1.9.1 Index]