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

Conflict with spatstat via units #523

Closed
andybega opened this issue Oct 17, 2017 · 4 comments
Closed

Conflict with spatstat via units #523

andybega opened this issue Oct 17, 2017 · 4 comments

Comments

@andybega
Copy link

Functions like st_length() that return an object with class "units" can produce a (false) error when the package "spatstat" is also attached due to a conflict between "units" and "spatstat":

library("sf")
library("units")

ex <- st_sfc(st_linestring(x = matrix(1:4, 2, 2)), crs = 4326)
# works
st_length(ex)

library("spatstat")
# does not work
st_length(ex)

The last line returns this error:

Error: $ operator is invalid for atomic vectors

This is misleading as st_length(ex) actually works correctly, it is the implicit print that fails because the wrong method is used:

str(st_length(ex))
units:::print.units(st_length(ex))
Class 'units'  atomic [1:1] 156759
  ..- attr(*, "units")=List of 2
  .. ..$ numerator  : chr "m"
  .. ..$ denominator: chr(0) 
  .. ..- attr(*, "class")= chr "symbolic_units"
156759.1 m

Not sure if this should be an issue here or at https://github.com/r-quantities/units, but it popped up when I was using sf in any case.

@edzer
Copy link
Member

edzer commented Oct 17, 2017

Oh, lovely. Yes, either there, or at https://github.com/spatstat/spatstat. It's in any case not an sf issue.

@edzer
Copy link
Member

edzer commented Oct 17, 2017

Changing the order of loading packages doesn't help; my guess is that that would have helped when spatstat would export print.units as an S3method, rather than as a symbol.

@andybega
Copy link
Author

andybega commented Oct 18, 2017

Thanks. I opened issues at both. I guess done as far as sf is concerned.

@edzer
Copy link
Member

edzer commented Oct 18, 2017

OK, thanks!

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

2 participants