hzambran / hydroGOF

Goodness-of-fit functions for comparison of simulated and observed hydrological time series
https://CRAN.R-project.org/package=hydroGOF
39 stars 13 forks source link

Problem with namespace exports #5

Closed tjmills closed 6 years ago

tjmills commented 7 years ago

I am guessing this is an issue with the namespace exports. When running gof with explicit call to namespace using hydroGOF::gof() the function fails with the following error:

Error in UseMethod("gof") : no applicable method for 'gof' applied to an object of class "c('double', 'numeric')"

Here is a reproducible example:

#Get some data
sim <- runif(1:1000)
obs <- runif(1:1000)

#Using namespace call function fails
hydroGOF::gof(sim=sim,
              obs=obs)

#Using library load function succeeds 
library(hydroGOF)
gof(sim=sim,
    obs=obs)
jthurner commented 7 years ago

Running your example works for me. Are you on the latest version?

search() # hydroGOF is not attached
##  [1] ".GlobalEnv"        "tools:rstudio"     "package:stats"    
##  [4] "package:graphics"  "package:grDevices" "package:utils"    
##  [7] "package:datasets"  "package:methods"   "Autoloads"        
## [10] "package:base"
sim <- runif(1:1000)
obs <- runif(1:1000)
gof(sim=sim,obs=obs)
## Error in gof(sim = sim, obs = obs): could not find function "gof"
hydroGOF::gof(sim=sim, obs=obs)
##            [,1]
## ME        -0.01
## MAE        0.32
## MSE        0.16
## RMSE       0.40
## NRMSE %  139.30
[...]
R.version.string
## [1] "R version 3.4.1 (2017-06-30)"
packageVersion("hydroGOF")
## [1] '0.3.10'
tjmills commented 7 years ago

Hi sorry for the super late response, I got pulled off on other things.

This example did run for me as well just now on my mac, but my issue was on our compute nodes. I will take a look at this more closely on that system and see what's up.