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 slab() #259

Merged
merged 26 commits into from
Oct 13, 2022
Merged

Updates to slab() #259

merged 26 commits into from
Oct 13, 2022

Conversation

brownag
Copy link
Member

@brownag brownag commented Aug 19, 2022

These are some updates that close #229

  • 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()
  • fixes mismatching lengths of slab labels v.s rows in data; allows for overlap; see .genSlabLabels2()

  • 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

    • add more documentation on arguments/patterns for custom functions, and ensuring extra arguments (or lack thereof)) work robustly
  • added a weighted variant of the numeric/quantile method via Hmisc::wtd.quantile(), and support for custom weighted functions (such as weighted.mean())

  • weighted variant of categorical method (created stub function .slab.fun.factor.weighted()) now in slab(): weighted variant of categorical method  #269

@brownag brownag marked this pull request as ready for review September 12, 2022 18:04
Copy link
Member

@dylanbeaudette dylanbeaudette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please have a look at specific comments. I would like to do some testing before fully converting the unweighted stuff to DT.

R/genSlabLabels.R Show resolved Hide resolved
R/segment.R Outdated Show resolved Hide resolved
tests/testthat/test-slab.R Show resolved Hide resolved
R/slab.R Show resolved Hide resolved
R/slab.R Show resolved Hide resolved
R/slab.R Show resolved Hide resolved
R/slab.R Outdated Show resolved Hide resolved
R/slab.R Outdated Show resolved Hide resolved
R/slab.R Outdated Show resolved Hide resolved
@brownag
Copy link
Member Author

brownag commented Sep 30, 2022

I had mentioned I wanted to check something with the different possible ways of specifying slab.structure. It appears that everything is working as expected. I will re-request a review, no rush on checking it over,

@dylanbeaudette
Copy link
Member

I thought of one potential issue, found last night while working on NCSP and dice: when using a formula that specifies all variables ~ . the horizon metadata variables will be included in the calculation of percent missing. This isn't usually a problem, but something to keep in mind as we move forward. slab always includes a named list of variables on the formula RHS, so this isn't a problem. We just need to be consistent in how we carry forward "horizon metadata", as a future plan for slab includes output as an SPC.

@brownag
Copy link
Member Author

brownag commented Sep 30, 2022

I thought of one potential issue, found last night while working on NCSP and dice: when using a formula that specifies all variables ~ . the horizon metadata variables will be included in the calculation of percent missing. This isn't usually a problem, but something to keep in mind as we move forward.

It's funny you mention this, since given the discussion we had on dice() with that type of formula I considered this in testing

slab always includes a named list of variables on the formula RHS, so this isn't a problem.

Yep. I think it would be cool if slab() could support the ~ . syntax.

We just need to be consistent in how we carry forward "horizon metadata", as a future plan for slab includes output as an SPC.

Yeah, agreed. Would like to see a method for converting slab output to SPC, I actually was going to draft one... and if we were to set that up... then we of course would need to address the metadata issue for consistency in "SPC methods that return SPCs"

brownag added a commit that referenced this pull request Oct 7, 2022
 - still needs testing/checking; encountered in setting up check dataset for #259
@brownag
Copy link
Member Author

brownag commented Oct 7, 2022

Assuming I navigated the parallel changes to master branch with the new "factor" check dataset correctly-- I find no difference between the v1 and v2 slab methods when using ~ genhz formula.

image

@brownag
Copy link
Member Author

brownag commented Oct 7, 2022

I've looked over the KSSL check code and made updates last weekend, the numeric discrepancy for that check set is in the Musick profiles that don't pass a logic check.

Remaining comments and questions:

  • Are the "changes" in value (generally small errors that result in very similar value after rounding) and contributing fraction acceptable? These differences only occur in the case of profiles that have invalid depth logic to begin with.
  • Is there any issue with contributing fraction calculation in new code? Are we properly accounting for overlaps and gaps that are now allowed as inputs?

@brownag
Copy link
Member Author

brownag commented Oct 13, 2022

From my testing I find that the cpm=2 argument also gives the same results for ~genhz formula between version 1 and 2.

@brownag brownag merged commit 640f9fe into master Oct 13, 2022
@brownag brownag deleted the slab1-brown branch October 13, 2022 20:32
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