ropensci / allodb

An R package for biomass estimation at extratropical forest plots.
https://docs.ropensci.org/allodb/
GNU General Public License v3.0
36 stars 11 forks source link

New validate equations #158

Closed maurolepore closed 3 years ago

maurolepore commented 3 years ago

This PR merges not into master but into another PR this one depends on: Ensure-equations-are-lowercase.

It adds a new function validate_equations() that helps validate equations, and also tests that all equations in the equations dataset are valid.

You may now call validate_equations() from inside any function that accepts equations from the user.

For example:

devtools::load_all()
#> ℹ Loading allodb

some_allodb_function_that_accepts_users_equations <- function(equations) {
  validate_equations(equations)

  # Do something interesting
}

valid <- c("dbh + 1", "h + 1")
some_allodb_function_that_accepts_users_equations(valid)

invalid <- c("dbh + 1", "h + bad")
try(some_allodb_function_that_accepts_users_equations(invalid))
#> Error : Every equation must be valid.
#> x Invalid: h + bad.
#> * Error: object 'bad' not found

Created on 2021-08-01 by the reprex package (v2.0.0)

gonzalezeb commented 3 years ago

ok. Merging to the New-validate_equations branch

gonzalezeb commented 3 years ago

wait, now how these commits are transferred to the master branch?

maurolepore commented 3 years ago

The'll will be added to master when Ensure-equations-are-lowercase gets merged into master.

maurolepore commented 3 years ago

Ooops, nope -- I forgot to ask to merge this pull request FIRST. No problem, I'll re-submit and we can merge it into master.