https://github.com/cran/aqp
Raw File
Tip revision: 07565ee5e1bca951c576b4ced02f3c459885bba2 authored by Dylan Beaudette on 06 September 2023, 21:32:38 UTC
version 2.0.1
Tip revision: 07565ee
split-SoilProfileCollection-method.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/split.R
\name{split,SoilProfileCollection-method}
\alias{split,SoilProfileCollection-method}
\title{Split a SoilProfileCollection object into a list of SoilProfileCollection objects.}
\usage{
\S4method{split}{SoilProfileCollection}(x, f, drop = TRUE, ...)
}
\arguments{
\item{x}{\code{SoilProfileCollection} object}

\item{f}{character vector naming a single site-level attribute that defines groups, a ‘factor’ in the sense that \code{as.factor(f)} defines the grouping, or a list of such factors in which case their interaction is used for the grouping.}

\item{drop}{logical indicating if levels that do not occur should be dropped (if f is a factor or a list). When \code{drop=FALSE} and \code{f} contains missing values an additional group "missing" is returned.}

\item{...}{additional arguments are ignored}
}
\value{
A list of \code{SoilProfileCollection} or \code{NULL} for empty result.
}
\description{
This function splits a \code{SoilProfileCollection} into a list of \code{SoilProfileCollection} objects using a site-level attribute to define groups or profile ID (\code{idname(x)}).
}
\details{
As of aqp 1.25, omission of \code{f} argument is no longer possible, as the base R generic is overloaded by this \code{SoilProfileCollection} method. This used to result in an "identity" split, according to \code{idname(x)}, e.g. a list as long as \code{length(x)}, with a single-profile \code{SoilProfileCollection} per list element. Replicate this behavior using \code{f = idname(x)} or \code{f = profile_id(x)}.
}
\examples{

data(sp2)
depths(sp2) <- id ~ top + bottom

# add a more interesting site-level attribute
site(sp2) <- ~ surface

# using identity site-level attribute (profile ID)
p1 <- split(sp2, f = idname(sp2))
names(p1)
length(p1)

# using vector equal in length to number of profiles (profile ID, again)
p2 <- split(sp2, f = profile_id(sp2))
names(p2)
length(p2)

# which are both equivalent to setting `f` to NULL
p3 <- split(sp2, f = NULL)
names(p3)
length(p3)

# split on surface (age) site-level var
p4 <- split(sp2, f = "surface")
names(p4)
length(p4) # 5 unique "surfaces", 5 SPCs in result list

}
\author{
D.E. Beaudette and A.G. Brown
}
back to top