[Rd] Dependency problem for "hasArg"

Mauricio Zambrano-Bigiarini mauricio.zambrano at jrc.ec.europa.eu
Mon Jul 2 17:06:11 CEST 2012


Dear list,

I'm running an R script which first line is:

#!/usr/bin/Rscript

While running that script from the system console (in Red Hat 
Enterprise Linux 6) I got the following error:


Error in plot2(x = sim, y = obs, plot.type = "single", main = 
paste("Daily",  :
   could not find function "hasArg"
Calls: plot_results -> plot_out -> ggof -> plot2


However, if I call EXACTLY the same script from the R console, by using

 > source("myRscript.R")

I do not get any error.


As you can see in the error message, the function 'plot_results' calls 
'plot_out' (both in the hydroPSO package). Then 'plot_out' calls the 
function 'ggof', which in turn calls 'plot2' (the latter 2 in the 
hydroGOF package), and 'plot2' has a call to 'hasArg'.


The package 'hydroGOF' exports all its functions by using:

exportPattern("^[^\\.]")

At the other hand, the package 'hydroPSO' does not import any function 
of the 'hydroGOF' package, because the call to 'ggof' only occurs within 
the 'plot_out' function if the hydroGOF package is detected on the user 
machine:

if (!require(hydroGOF)) {
      stop("Invalid argument: You don't have the 'hydroGOF' package !!")
} else {
   library(hydroGOF)
   ggof()
}

Do I have to explicitly import 'ggof' and 'plot2' on the 'hydroPSO' 
package in order to avoid this error or is there any better solution ?

sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-redhat-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C
  [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8
  [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8
  [7] LC_PAPER=C                LC_NAME=C
  [9] LC_ADDRESS=C              LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] lhs_0.7          hydroPSO_0.1-57  hydroGOF_0.3-3-1 hydroTSM_0.3-4-5
[5] xts_0.8-6        Lisflood_0.2-10  zoo_1.7-7

loaded via a namespace (and not attached):
  [1] automap_1.0-12 class_7.3-4    cluster_1.14.2 e1071_1.6 
grid_2.15.0   [6] gstat_1.0-12   Hmisc_3.9-3    lattice_0.20-6 
proj4_1.0-7    rgdal_0.7-12  [11] sp_0.9-99      tools_2.15.0



Any help would be very much appreciated.

Kind regards,

Mauricio Zambrano-Bigiarini

-- 
====================================================
Water Resources Unit
Institute for Environment and Sustainability (IES)
Joint Research Centre (JRC), European Commission
webinfo    : http://floods.jrc.ec.europa.eu/
====================================================
DISCLAIMER:\ "The views expressed are purely those of th...{{dropped:11}}



More information about the R-devel mailing list