Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

problem with summarizing SpatialPointsDataFrame #16

Open
jebyrnes opened this issue Mar 27, 2018 · 1 comment
Open

problem with summarizing SpatialPointsDataFrame #16

jebyrnes opened this issue Mar 27, 2018 · 1 comment

Comments

@jebyrnes
Copy link

I'm wondering if the move to dplyr 0.7 caused some issues.

library(sp)
library(spdplyr)


data(meuse)

coordinates(meuse) <- ~x+y

meuse %>% 
  group_by(landuse) %>%
  summarize(zinc = mean(cadmium))

throws

Error in arrange_impl(.data, dots) : 
  Evaluation error: Column `branch_`: not found in data.

which seems odd...

@mdsumner
Copy link
Owner

Ah, no - it's just something I never tested. The logic this sits in is a bit convoluted and in some ways was just me learning how to use dplyr, it could be a lot better but I'd prefer to just do

meuse %>%  as.data.frame() %>%
  group_by(landuse) %>%
  summarize(zinc = mean(cadmium))

it could create a multipoint to make it coherent with what group_by/summarize does to polygons and lines - but I consider this low priority given that using sf will now be much more consistent.

here's an sf approach:

library(sf)

meuse %>% st_as_sf() %>% 
  group_by(landuse) %>%
  summarize(zinc = mean(cadmium))

Happy to help you find a better way rather than use spdplyr, are you happy to ignore this and leave spdplyr behind?

(Thanks for reporting the issue, I still might fix it just for the sake of learning)

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

No branches or pull requests

2 participants