-
Notifications
You must be signed in to change notification settings - Fork 13
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
add checks for illogical slab() structure #24
Comments
Updated reprex. 2 of 3 items from OP are resolved now after prior slab upgrades. library(aqp)
#> This is aqp 2.0.3
data("jacobs2000", package="aqp")
# same depth: properly errors
slab(jacobs2000, ~clay, slab.structure = c(50, 50))
#> Error: Invalid slab.structure
# large bottom depth: works as it should
slab(jacobs2000, ~clay, slab.structure = c(50, 10000))
#> variable all.profiles p.q5 p.q25 p.q50 p.q75 p.q95 contributing_fraction top
#> 1 clay 1 0.4 2 20 39 47 0.01305097 50
#> bottom
#> 1 10000 The depth logic error still needs a message/handling: # depth logic error: needs informative message
slab(jacobs2000, ~clay, slab.structure = c(75, 50))
#> Error in rep(1, j[x]): invalid 'times' argument Also, related to the very deep bottom depth above, with very large numbers, there is a limit in the formula parsing code used in This can be fixed in the regex dice uses to get terms of the formula by ignoring the # integer values: scientific notation breaks parsing depending on scipen option (>=1e5)
slab(jacobs2000, ~clay, slab.structure = c(50, 100000))
#> Error in parse(text = fm[[1]]): <text>:1:4: unexpected input
#> 1: 50:1e
#> ^
slab(jacobs2000, ~clay, slab.structure = c(50, 1e5))
#> Error in parse(text = fm[[1]]): <text>:1:4: unexpected input
#> 1: 50:1e
#> ^
slab(jacobs2000, ~clay, slab.structure = c(50, 100000L))
#> Error in parse(text = fm[[1]]): <text>:1:4: unexpected input
#> 1: 50:1e
#> Setting options(scipen=99)
slab(jacobs2000, ~clay, slab.structure = c(50, 100000))
#> variable all.profiles p.q5 p.q25 p.q50 p.q75 p.q95 contributing_fraction top
#> 1 clay 1 0.4 2 20 39 47 0.001299221 50
#> bottom
#> 1 100000 Related to #106, although considering slab function arguments rather than input data depths. I don't know whether slab should force # decimal values: constant slab interval, works but output depths converted to integer
slab(jacobs2000[1,], ~clay, slab.structure = c(5.5)) |> head()
#> variable all.profiles p.q5 p.q25 p.q50 p.q75 p.q95 contributing_fraction top
#> 1 clay 1 7 7 7 7 7 1 0
#> 2 clay 1 7 7 7 7 7 1 5
#> 3 clay 1 7 7 7 7 7 1 11
#> 4 clay 1 6 6 7 7 7 1 16
#> 5 clay 1 6 6 6 6 6 1 22
#> 6 clay 1 6 6 6 6 6 1 27
#> bottom
#> 1 5
#> 2 11
#> 3 16
#> 4 22
#> 5 27
#> 6 33 For the more general ideas in #106, I think changing The following still don't work: # decimal values: single interval slab structure, index breaks
slab(jacobs2000, ~clay, slab.structure = c(5.5, 10))
#> Error in `[<-.data.frame`(`*tmp*`, , g, value = 1): replacement has 1 row, data has 0
slab(jacobs2000, ~clay, slab.structure = c(5.5, 10.5))
#> Error in `[<-.data.frame`(`*tmp*`, , g, value = 1): replacement has 1 row, data has 0
# decimal values: multiple interval slab structure with decimals returns nothing
slab(jacobs2000, ~clay, slab.structure = c(5.5, 10.5, 15.5))
#> [1] variable all.profiles p.q5
#> [4] p.q25 p.q50 p.q75
#> [7] p.q95 contributing_fraction top
#> [10] bottom
#> <0 rows> (or 0-length row.names) |
Encountered this error when trying to calcualate slab means on the control section.
Need to add checks in slab to verify:
Reproducible example (until the data are fixed in NASIS):
slabbing function for control section
Case 1
Case 2
both result in:
Case 3
results in:
Error in rep(NA, times = max.d - slab.structure[2]) : invalid 'times' argument
The text was updated successfully, but these errors were encountered: