build.profile: Converts a data.frame into a profile.data.frame

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/build.profile.R

Description

This function simply converts a data.frame into an object of class profile.data.frame. A table can be provided with suitable names (as in the arguments of the function) or single vectors.

Usage

1
2
3
build.profile(table, Profile = NULL, name = NULL, depth = NULL, col = NULL,
skel_dim = NULL, skel_ab = NULL, type = NULL, root_ab = NULL,
root_dim = NULL, orientation = NULL)

Arguments

table

A data.frame containing the variables needed to draw a soil profile. If a variable with the required name is missing, the function looks for it in subsequent arguments (with a warning).

Profile

A vector containing coding of profiles. Multiple profiles are allowed in the same dataframe. Profiles may be in any format.

name

A vector containing the code for each single horizon. Horizons are allowed in usual form (e.g. A1, Bw, etc.) or as transition horizons (O/A) or as 'cumulative' horizons as it usually occurs for O horizons (Oi-Oe-Oa).

depth

A vector of depths. Depth must be in the form of upper_boundary - lower_boundary. Irregular boundaries are allowed and may be indicated in the form lower1/lower2. See examples for details.

col

A vector of colors in the form hue value/chroma. Vectors are passed to 'as.character' for conversion. Hue and chroma must be strictly separated by a space, whereas chroma and value by a '/'. Non integer numbers for hue and chroma are rounded.

skel_dim

A numeric vector of skeletal dimensions in cm.

skel_ab

A numeric vector of skeletal aboundance in the range 0-1.

type

A character vector indicating the type of skeletal unit. Three types of skeletal shape are allowed. 'subangular', 'subcircle' and 'channer'. The basic shape is loaded from a matrix of coordinates.

root_ab

A character vector giving the root abundance expressed qualitatively. Available abundances are 'absent', 'few', 'common', 'many'. Those qualitative indices are choosen according to the international classification systems.

root_dim

A numeric vector providing the dimension of roots given in cm.

orientation

A character vector to be chosen between 'v' and 'h' to indicate main orientation of the root system, vertical and horizontal, respectively.

Details

This function converts a data.frame in an object of class 'profile.data.frame'. This class has dedicated methods such as summary, head, tail, plot, etc. See examples for more details. In the easiest case, a data.frame can be passed to this function, which already has proper column names (as in the arguments of the function) of a 'profile.data.frame'. If not, each vector must be provided in the proper argument of the function. Warnings are set in order to facilitate this process of conversion. Additional data (e.g. chemical or physical data associated to the profiles' horizons) are arranged with unchanged names after the 10 required columns.

Value

An object of class 'profile.data.frame'. This object is actually a list, and only few basic methods have been defined to explore it (eg. 'summary', 'head', 'tail', 'plot', eplot'). All other functions will treat this class as a list and therefore lead to meaningless results.

Author(s)

Gianluca Filippa

See Also

'plot.profile.data.frame', 'plot.element'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
##rename
tmp <- example
## back to class data.frame 
class(tmp) <- 'data.frame'
## back again to the 'profile.data.frame' class  
profile.data <- build.profile(tmp)
## if the table is not complete, we remove the Profile column 
tmp2 <- tmp[,-1]
##running the following will return a warning
profile.data <- build.profile(tmp2)
##and Profile column is NA
head(profile.data)
##
Profile <- tmp[,1]
##check information in output when we add the Profile vector  
profile.data <- build.profile(tmp2, Profile=Profile)

Example output

Loading required package: aqp
This is aqp 1.10
Loading required package: lattice
Loading required package: munsell
Loading required package: splancs
Loading required package: sp

Spatial Point Pattern Analysis Code in S-Plus
 
 Version 2 - Spatial and Space-Time analysis

[1] "looking for a vector with Profile"
[1] "PROFILE IS MISSING!"
  Profile name depth skel_dim skel_ab       col      type  root_ab root_dim
1      NA   C1   0-8       10     0.7    5Y 5/3 subcircle      few      0.2
2      NA   C2  8-40       20     0.7    5Y 6/1 subcircle   absent       NA
3      NA   OL   0-1       NA      NA   5YR 2/1               many      0.2
4      NA   OF   1-3       NA      NA 7.5YR 2/1               many      0.2
5      NA    A   3-7        3     0.2  10YR 4/2 subcircle abundant      0.5
6      NA   CB  7-18       10     0.5  10YR 5/4 subcircle   common      0.5
  orientation age  pH  Corg  C.N    IS  Feo  Fed
1           v   6 6.6  0.04   NA 0.065 0.09 0.19
2               6 6.8  0.00   NA 0.060 0.08 0.15
3              60  NA    NA   NA    NA   NA   NA
4              60 5.9 26.58 20.2    NA   NA   NA
5           v  60 5.8  1.50 14.4 0.085 0.11 0.19
6           v  60 5.8  0.44 13.4 0.110 0.14 0.25
[1] "looking for a vector with Profile"
[1] "Profile found"

soilprofile documentation built on May 29, 2017, 10:50 p.m.