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

Ensure all equations contain valid R code #38

Closed maurolepore closed 3 years ago

maurolepore commented 6 years ago

I plan to write a test to automatically check that each equation can be evaluated -- i.e. that it contains valid R code. Once that is done, we'll be able to press Control + Shift + T to run this (and all other) test, and we'll get an informative error message if some equation isn't valid R code.

maurolepore commented 6 years ago

@gonzalezeb, here I point to some equations that currently contain invalid code and I suggest the solutions. Let me know if you have questions or need help.

maurolepore commented 6 years ago

image

gonzalezeb commented 6 years ago

This is great Mauro. Two fixes can be applied now and I will work on the other two:

fix_problem("attempt", "([0-9])(\(log10)", "\1 * \2")
fix_problem("unexpected ')'", "\)$", "")

A questions for you: I would like the changes to be applied to our master table (data-raw/allodb-master) but as the code is written now changes would be applied to data/equations. How do I work around it?

maurolepore commented 6 years ago

You are right, the equations come from the equation table, and the changes are not applied back to any table.

eqn <- equations$equation_allometry`.

You could do something like this:

# Inputs a vector and outputs a dataframe
fixed_dataframe <- fix_problem(master$equations, ...)

master$equations <- fixed_dataframe$equations

This kind of "find and replace" you could also do in excel. But go for it if you want to do it in R. I think it's the best way to learn.

gonzalezeb commented 6 years ago

I reviewed and fixed the equations (the easiest way!). thanks Mauro. For dba or what I call, the srub problem please see issue #41

maurolepore commented 6 years ago

(Details.)

Great work @gonzalezeb; thanks!

Now all except one error relates to 'dba', which I'll follow up in #41. The exception relates to 'BA'. I had missed this error before. What should we do about it?

image

maurolepore commented 6 years ago

Relates to #54 .