jranke / pfm

R package with utilities for pesticide fate modelling
1 stars 0 forks source link

PEC_sw_drift not vectorized #2

Open juklei opened 2 months ago

juklei commented 2 months ago

Hi Hannes.

Another thing on Julian's wishlist:-)

The function is not vectorized if the user wants to supply the function with crop groups. The application of PEC_sw_drift() to a large data set via apply becomes computationally very time consuming. If crop group is not supplied, the function is vectorized.

I assume the vectorisation can be made possible by changing

crop_group_RF <- match.arg(crop_group_RF)

to

crop_group_RF <- sapply(crop_group_RF, match.arg)

But further changes migth be necessary...

jranke commented 2 months ago

Hi Julian, unfortunately this does not work, I get test failures with this proposed change.

It seems we would need some other way to check the validity of the argument(s) for crop_group_JKI and crop_group_RF if we want to vectorize.

Cheers, Hannes