Skip to content

aggregate in sf #286

@GreenStat

Description

@GreenStat

Hi,
not sure if this is an error, bug or lack of documentation ....

with this sf object

library(sf)
library(tidyverse)

data(meuse, package = "sp")
meuse_sf = st_as_sf(meuse, coords = c("x", "y"), crs = 28992, agr = "constant")
#  
meuse_sf %>% str
# suppresed output

I tried aggregate with several options:

meuse_sf %>% aggregate(by=list(meuse_sf$soil))
Error in match.fun(FUN) : argument "FUN" is missing, with no default
#oke we need FUN

meuse_sf %>% aggregate(by=list(meuse_sf$soil), FUN="first")
Error in aggregate.data.frame(x, list(Group.1 = by), FUN, ..., simplify = FALSE) : 
  arguments must have same length

I also tried other options for FUN (mean, max etc) and with 'union=TRUE' but nothing seems to work

NB in sp this works

aggregate(as(meuse_sf,'Spatial'),by=list(meuse_sf$soil), FUN="first") 

Any thoughts ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions