Skip to content

Commit

Permalink
almost ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Feb 12, 2021
1 parent 8311498 commit dfa98a4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions misc/sandbox/dice.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,21 @@ plotSPC(d[1:10, ], color = 'p1')
# https://github.com/ncss-tech/aqp/issues/115


# simpler, faster version of slice via data.table / FULL JOIN
# simpler, faster version of slice via `data.table` / FULL JOIN
# less robust to errors than current slice()
# slices entire profiles
# returns all columns
# returns all depths / columns

#' @param x a `SoilProfileCollection` object
#' @param dropInvalid drop profiles with horizon errors
#' @param just.the.data return only the horizon data, for backwards compatibility
#' @param SPC return the diced `SoilPrfolileCollection`, if `FALSE` a `data.frame` of horizon-level attributes
#'
dice <- function(x, dropInvalid = TRUE, just.the.data = FALSE) {
dice <- function(x, dropInvalid = TRUE, SPC = TRUE) {

## TODO:
# * consider setindex() vs. setkey() <-- this sorts the data
# * formula interface
# * .pctMissing eval
# * return as DF vs. SPC
# * formula interface (nope)
# * .pctMissing eval (write a new function)
# * strictness of hz logic eval
# * ERRORS on NA depths
# * ERROR on top == bottom
Expand Down Expand Up @@ -107,6 +106,10 @@ dice <- function(x, dropInvalid = TRUE, just.the.data = FALSE) {
# re-name for simpler JOIN
names(s)[1] <- hzidn

## MAYBE
# perform subsetting of depths / variables using `fm` if provided
# s[.sliceTop %in% depthvec]

## TODO: are keys worth the extra sorting / re-sorting?
# note: sorts data
# setkeyv(s, hzidn)
Expand Down Expand Up @@ -190,7 +193,7 @@ system.time(s <- dice(d))
# get.slice() wastes a lot of time
pp.slice <- profvis(s <- slice(d, 0:100 ~ .))

# most time spent: setkey + mapply + setkey
# most time spent: checHzDepthLogic + mapply
pp.dice <- profvis(s <- dice(d))


Expand Down

0 comments on commit dfa98a4

Please sign in to comment.