On 31/10/16 09:12, Roger Bivand wrote: > On Mon, 31 Oct 2016, Edzer Pebesma wrote: > >> >> >> On 31/10/16 05:09, Li Jin wrote: >>> Hi All, >>> >>> I need to use the predict{gstat} function in one of my functions for >>> a R package. I use RStudio to make the package. When I specified >>> gstat::predict in the function, I received the following error: >>> >>> Error: 'predict' is not an exported object from 'namespace:gstat' >> >> gstat exports 'predict' as an S3method; if it would export 'predict' as >> an object, this would hide the generic in package stats. >> >> The solution to your problem is to not put prepend 'predict' with >> gstat::, but instead rely on S3 method dispatch. > > Is it possible that the OP is not importing correctly in the NAMESPACE > file of the package in question?
Indeed: your package should load (import): 1. predict from package stats, if it wants to use predict 2. package gstat if it wants to use the predict method for gstat objects. 3. use stats::predict rather than gstat::predict if you'd insist on prepending package:: to a generic > > Roger > >> >> The actual, un-exported function called is gstat:::predict.gstat, but it >> is discouraged to call that directly. >> >>> >>> The session information is: >>> >>>> sessionInfo() >>> >>> R version 3.3.1 (2016-06-21) >>> >>> Platform: x86_64-w64-mingw32/x64 (64-bit) >>> >>> Running under: Windows 7 x64 (build 7601) Service Pack 1 >>> >>> >>> >>> locale: >>> >>> [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 >>> >>> [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C >>> >>> [5] LC_TIME=English_Australia.1252 >>> >>> >>> >>> attached base packages: >>> >>> [1] stats graphics grDevices utils datasets methods base >>> >>> >>> >>> other attached packages: >>> >>> [1] myrpackage_0.0.0.9000 devtools_1.12.0 >>> >>> >>> >>> loaded via a namespace (and not attached): >>> >>> [1] tools_3.3.1 withr_1.0.2 memoise_1.0.0 digest_0.6.10 >>> >>> Is this a bug? Any suggestions? Many thanks in advance! >>> >>> Kind regards, >>> Jin >>> >>> Jin Li, PhD >>> Spatial Modeller/Computational Statistician | National Earth and >>> Marine Observations >>> Environmental Geoscience Division | GEOSCIENCE AUSTRALIA >>> ____________________________________________________________ >>> Phone: +61 2 6249 9899 Fax: +61 2 6249 9999 >>> Email: jin...@ga.gov.au<mailto:jin...@ga.gov.au> Web: >>> www.ga.gov.au<http://www.ga.gov.au/> >>> 101 Jerrabomberra Avenue Symonston ACT >>> GPO Box 378 Canberra ACT 2601 Australia >>> Applying geoscience to Australia’s most important challenges >>> >>> >>> >>> Geoscience Australia Disclaimer: This e-mail (and files transmitted >>> with it) is intended only for the person or entity to which it is >>> addressed. If you are not the intended recipient, then you have >>> received this e-mail by mistake and any use, dissemination, >>> forwarding, printing or copying of this e-mail and its file >>> attachments is prohibited. The security of emails transmitted cannot >>> be guaranteed; by forwarding or replying to this email, you >>> acknowledge and accept these risks. >>> ------------------------------------------------------------------------------------------------------------------------- >>> >>> >>> >>> [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> R-sig-Geo mailing list >>> R-sig-Geo@r-project.org >>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >>> >> >> > -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081 Journal of Statistical Software: http://www.jstatsoft.org/ Computers & Geosciences: http://elsevier.com/locate/cageo/
signature.asc
Description: OpenPGP digital signature
_______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo