Reputation: 631
I'm developing my first package - well, actually I'm packaging some existing code - in RStudio. I've marked up all the comments with roxygen2 and this has generated a correct NAMESPACE file which includes:
import(sp)
importFrom(geosphere,distMeeus)
importFrom(geosphere,distm)
I'm using the distm()
function from the geosphere package to calculate a distance matrix but it is failing:
Error in .pointsToMatrix(x) : could not find function "is.projected" 4 .pointsToMatrix(x) 3 distm(OCC, SPAD, fun = distMeeus) at peta.R#79
now is.projected()
is in the sp package, which I have imported so it should be in my search path. Shouldn't it?
As an experiment I just called library(geosphere)
(which also loads sp) prior to calling my package code and my function got past that point. Soooo, do I still need to call library()
for every package??? That seems a bit redundant and at this point I think I'll stop and see if someone can set me straight before I break anything further...
Upvotes: 0
Views: 797
Reputation: 179398
Edited
I don't understand why this is, but you need to add methods
to your package imports:
Add to your DESCRIPTION
:
Imports: methods
Add to your NAMESPACE:
import(methods)
Upvotes: 1