You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Those tidyverse methods in tidygraph that recreate the network when removing nodes do not preserve the agr attributes from the sf object. It comes from the igraph::delete_vertices() function that is recreating the network. So far I found this for
filter.tbl_graph()
slice.tbl_graph() and their slice_*.tbl_graph() functions
distinct.tbl_graph()
Reproducible example
library(sfnetworks)
library(tidygraph)
library(tidyverse)
library(sf)
#> Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.5.0; sf_use_s2() is TRUEnet= as_sfnetwork(roxel)
net|>
activate(edges) |>
st_agr()
#> from to name type #> <NA> <NA> constant constant #> Levels: constant aggregate identity# filter.tbl_graph()net|>
mutate(foo= sample(1:5, 987, replace=TRUE)) |>
filter(foo==2) |>
activate(edges) |>
st_agr()
#> from to name type #> <NA> <NA> <NA> <NA> #> Levels: constant aggregate identity# slice.tbl_graph()net|>
slice(3:7) |>
activate(edges) |>
st_agr()
#> from to name type #> <NA> <NA> <NA> <NA> #> Levels: constant aggregate identity# slice_sample.tbl_graph()net|>
slice_sample(n=20) |>
activate(edges) |>
st_agr()
#> from to name type #> <NA> <NA> <NA> <NA> #> Levels: constant aggregate identity# distinct.tbl_graph()net|>
distinct() |>
activate(edges) |>
st_agr()
#> from to name type #> <NA> <NA> <NA> <NA> #> Levels: constant aggregate identity
Expected behavior
The agr attributes are preserved.
Describe the bug
Those tidyverse methods in tidygraph that recreate the network when removing nodes do not preserve the agr attributes from the sf object. It comes from the
igraph::delete_vertices()
function that is recreating the network. So far I found this forfilter.tbl_graph()
slice.tbl_graph()
and theirslice_*.tbl_graph()
functionsdistinct.tbl_graph()
Reproducible example
Expected behavior
The agr attributes are preserved.
R Session Info
sfnetworks v1.0 branch
The text was updated successfully, but these errors were encountered: