From 716843b2aeda9e26b24945b4ce6c6f4029a54fed Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Sun, 14 Jun 2020 13:41:49 -0700 Subject: [PATCH] new classification of aqp functions using regex -- sorting stuff out for aqp2 --- man/clod.hz.ids.Rd | 41 ------------------ misc/aqp2/function-dependencies.R | 69 +++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 48 deletions(-) delete mode 100644 man/clod.hz.ids.Rd diff --git a/man/clod.hz.ids.Rd b/man/clod.hz.ids.Rd deleted file mode 100644 index c8c683366..000000000 --- a/man/clod.hz.ids.Rd +++ /dev/null @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/glom.R -\name{clod.hz.ids} -\alias{clod.hz.ids} -\title{Return index to all horizons occuring in a depth interval} -\usage{ -clod.hz.ids(p, z1, z2 = NA, modality = "all", as.list = FALSE) -} -\arguments{ -\item{p}{A single-profile SoilProfileCollection} - -\item{z1}{Top depth (required) - depth to intersect horizon at; if 'z2' specified, top depth of intersect interval.} - -\item{z2}{Top depth (required) - depth to intersect horizon at; if 'z2' specified, top depth of intersect interval.} - -\item{modality}{Return all data (default: "all") or first, thickest (\code{modality = "thickest"}) horizon in interval.} - -\item{as.list}{OPTIONAL: return a list? default: FALSE} -} -\value{ -A vector of unique horizon IDs. -} -\description{ -\code{clod.hz.ids} returns a vector of unique indices corresponding to a depth interval. As arguments, it takes a single-profile SoilProfileCollection 'p', a top depth 'z1' and an optional bottom depth 'z2'. - -If just top depth is specified, the unique index of the horizon intersected by that depth is returned. If bottom depth is specified, all horizon IDs that are intersected by the depth interval are returned. -} -\details{ -This function is a workhorse used by glom() to create an index of unique horizon IDs intersecting the attribute of interest (depth) at the specified levels. This function returns the horizon IDs required to index an SPC and produce either a subset SPC or data.frame representation of the "clod" returned. -} -\examples{ -data(sp1, package = 'aqp') -depths(sp1) <- id ~ top + bottom -site(sp1) <- ~ group -p <- sp1[1] -foo <- clod.hz.ids(p, 25, 100) -foo -} -\author{ -Andrew G. Brown -} diff --git a/misc/aqp2/function-dependencies.R b/misc/aqp2/function-dependencies.R index 1fdea8b97..8527e9560 100644 --- a/misc/aqp2/function-dependencies.R +++ b/misc/aqp2/function-dependencies.R @@ -1,9 +1,64 @@ -#devtools::install_github("datastorm-open/DependenciesGraphs") -library(DependenciesGraphs) -library(aqp) +# functions +aqp.functions <- getNamespaceExports("aqp") +aqp.functions <- aqp.functions[-grep("_[TC]_", aqp.functions)] +aqp.grp <- vector('list') -deps <- funDependencies("package:aqp", "getArgillicBounds") -plot(deps) +# plotting functions +plot.idx <- grep("[Pp]lot|add|find|fix|segments", aqp.functions) +aqp.grp[['plot']] <- sort(aqp.functions[plot.idx]) +aqp.functions <- aqp.functions[-plot.idx] -edeps <- envirDependencies("package:aqp") -plot(edeps) +# soil color +color.idx <- grep("[Cc]olor|red|dark|melan|rubif|[Mm]unsell|rgb|contrast|hue|buntley|Palette", aqp.functions) +aqp.grp[['color']] <- sort(aqp.functions[color.idx]) +aqp.functions <- aqp.functions[-color.idx] + +# soil texture +texture.idx <- grep("tex", aqp.functions) +aqp.grp[['texture']] <- sort(aqp.functions[texture.idx]) +aqp.functions <- aqp.functions[-texture.idx] + +# soilprofilecollection operations +spccalc.idx <- grep("sim|get|estim|clay|mollic", aqp.functions) +aqp.grp[['spccalc']] <- sort(aqp.functions[spccalc.idx]) +aqp.functions <- aqp.functions[-spccalc.idx] + +spc.idx <- grep("^l?un|split|SPC|spc|[Hh]orizon|[Ss]ite|subset|filter|mutate|[Pp]rofile|Apply|glom|<-|[Hh]z|id|length|nrow|min|max|[Dd]epthOf|coord|proj|denorm|meta|restrict|aqp|check|guess", aqp.functions) +aqp.grp[['spc']] <- sort(aqp.functions[spc.idx]) +aqp.functions <- aqp.functions[-spc.idx] + +# aggregate profiles +spc.agg.idx <- grep("aggregate|eval|slice|[Ss]lab|group|summarize|pc", aqp.functions) +aqp.grp[['spcagg']] <- sort(aqp.functions[spc.agg.idx]) +aqp.functions <- aqp.functions[-spc.agg.idx] + +# xrd +xrd.idx <- grep("noise|twotheta", aqp.functions) +aqp.grp[['xrd']] <- sort(aqp.functions[xrd.idx]) +aqp.functions <- aqp.functions[-xrd.idx] + +# classification +tau.idx <- grep("[Tt]au|confusion|shannon|brier", aqp.functions) +aqp.grp[['classification']] <- sort(aqp.functions[tau.idx]) +aqp.functions <- aqp.functions[-tau.idx] + + +lapply(aqp.grp, length) + +View(aqp.grp) + +# devtools::install_github("datastorm-open/DependenciesGraphs") +# +# library(DependenciesGraphs) +# library(aqp) +# deps <- funDependencies("package:aqp", "getArgillicBounds") +# plot(deps) +# # +# edeps <- envirDependencies("package:aqp") +# plot(edeps) + +library(mvbutils) +library(aqp) +library(reshape) +ixWhere <- match(c("package:aqp","package:reshape"), search()) +foodweb(where = ixWhere, prune = ls("package:reshape"), descendents = FALSE)