mikejohnson51 / climateR

An R 📦 for getting point and gridded climate data by AOI
https://mikejohnson51.github.io/climateR/
MIT License
168 stars 40 forks source link

Explicit scoping for param_meta in define.param #23

Closed mbjoseph closed 3 years ago

mbjoseph commented 3 years ago

Hey @mikejohnson51! I'm incorporating climateR into a downstream package, but running into scoping issues.

When my package calls getMACA, the following error is raised:

Error in eval(parse(text = paste0("param_meta$", service))) : 
  object 'param_meta' not found

The traceback indicates that this is raised when climateR::define.param is called by climateR::getMACA:

image

Proposed solution

Modifying this line to use climateR::param_meta instead of param_meta solves the issue: https://github.com/mikejohnson51/climateR/blob/master/R/utility_define_param.R#L12

I noticed that you've explicitly specified the scope like this elsewhere where eval() is used, e.g.,

https://github.com/mikejohnson51/climateR/blob/fe7414903aa0f0a5ac3149c36c7e3401e92972c9/R/utility_define_config.R#L10

and

https://github.com/mikejohnson51/climateR/blob/fe7414903aa0f0a5ac3149c36c7e3401e92972c9/R/utility_define_config.R#L34

mikejohnson51 commented 3 years ago

I think this should be taken care of, thanks again @mbjoseph!

mbjoseph commented 3 years ago

cool - thanks @mikejohnson51! :+1: