Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to dice(), slab(), genSlabLabels() #258

Closed
wants to merge 7 commits into from
Closed

Conversation

brownag
Copy link
Member

@brownag brownag commented Aug 18, 2022

These are some updates that resolve some tasks from #115, and implements #229

Notably, slab() now uses dice() so users will not get confused when they get a deprecation message RE: slice() while using slab(). I have had several questions from users about this (essentially: how do I use dice() with slab()?)

library(aqp)
#> This is aqp 1.43
data(sp1, package = 'aqp')
depths(sp1) <- id ~ top + bottom
a.max <- slab(sp1, fm = ~ prop)
#> Note: aqp::slice() will be deprecated in aqp version 2.0
#> --> Please consider using the more efficient aqp::dice()

This PR has attempted to cover / ensure that the following are addressed:

  • issues related to the fm = 0:z ~ . results in z+1 slices (fixed insofar as they affect slab(), I don't think it is fully fixed on dice() side yet)
  • handled 0 thickness horizons in slab(), whether or not strict=TRUE
  • fixed mismatching lengths of slab labels v.s rows in data
  • added and exported slab_function() a helper method for accessing the internal slab methods provided by the package; now used in method definitions rather than internal functions (could use more documentation on arguments/patterns for custom functions, and ensuring extra arguments all works)
  • added a weighted variant of the numeric/quantile method via Hmisc::wtd.quantile(), and support for custom weighted functions (such as weighted.mean())

I am sure this has not yet caught everything, but I spent some time ensuring all the existing tests worked, and added some more that stress a few other features, as well as new tests for the now-implemented weights argument. It all appears to be functioning as expected in the test cases, though I bet there are still edge cases or un-tested use cases that still have issues.

@brownag
Copy link
Member Author

brownag commented Aug 18, 2022

One more note: I added a stub for a "weighted categorical/factor" aggregation function, but it currently does nothing. I think I might need to spend a little more time looking at the cpm/"class probability mode" logic before I get into thinking about NA handling and weighting for categories.

@brownag brownag linked an issue Aug 18, 2022 that may be closed by this pull request
@dylanbeaudette
Copy link
Member

I haven't finished an in-depth review, but before this gets too complex I'd like to split the dice/slab changes into two pieces. I don't know how to work the git magic to do that, will need your help on that. This is a complex tangle. Also, I think that these changes (finally) to slice, slab, dice, etc. warrant a 2.0 release.

 - `slab()`: replace slice() with dice()
 - `dice()`: address some TODOs
 - Add `slab_function()`
 - add test of "component weighted averages"
…ents to avoid errors

 - explicitly support `na.rm` where appropriate (defaults to true)
@brownag
Copy link
Member Author

brownag commented Aug 19, 2022

So you are asking for two pull requests, one for dice and one for slab/genSlabLabels?

PR has been split into two draft PRs. The slab() PR branches from / depends on the changes in dice():

@brownag brownag closed this Aug 19, 2022
@brownag brownag deleted the slabDice1 branch August 23, 2022 02:38
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement weights argument for slab()
2 participants