Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: 'aggregate' is not an exported object from 'namespace:sp #43

Closed
antaldaniel opened this issue Nov 25, 2017 · 4 comments
Closed

Comments

@antaldaniel
Copy link

I am trying to use sp in a package and would need to refer to the aggregate function. However, I get this error, that had been around on various forums.
cnames <- sp::aggregate(cbind(long, lat) ~ id, data=final.plot, FUN=function(x) mean(range(x)))

I am getting
Error: 'aggregate' is not an exported object from 'namespace:sp'

In this case no packages are reloaded (no raster) so there is no name conflict. How can I refer to aggregate?

@edzer
Copy link
Owner

edzer commented Nov 25, 2017

It is exported as an S3 generic for Spatial objects. So you package has to import sp, and then you can use it without the sp:: prefix (which only works for exported functions) if the first argument is of class Spatial (not so sure this is the case for your example).

@antaldaniel
Copy link
Author

Hi, thanks for the reply, and thanks for the bit stupid question. There were a lot of old questions about this on various forums, so I thought to bring it here. What you write makes sense and works. I just moved sp from Imports to Dependencies, and unlike with other functions imported the whole sp package. I also added methods to imports, because the handling of S3 methods is in fact a package that is part of the basic R infrastructure. Thanks.

@edzer
Copy link
Owner

edzer commented Nov 26, 2017

Good to hear that it works. It shouldn't be needed to have sp in Depends: if you only need to use this in your package.

@edzer edzer closed this as completed Nov 26, 2017
@reginaldo-re
Copy link

This issue is a little bit tricky because the disaggregate method is exported but the aggregate method does not. So, someone can use sp::disaggregate() but can't use sp::aggregate().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants