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

filter() fails on grouped data #193

Open
hughjonesd opened this issue Jun 21, 2024 · 0 comments
Open

filter() fails on grouped data #193

hughjonesd opened this issue Jun 21, 2024 · 0 comments

Comments

@hughjonesd
Copy link

Here's a reprex:

library(ggraph)
data(whigs)

whigs <- tidygraph::as_tbl_graph(whigs) |> 
  activate(nodes) |> 
  mutate(AM = grepl("^[A-M]", name)) 

# Works fine:
whigs |> filter(grepl("Austin", name))
# A tbl_graph: 2 nodes and 0 edges
#
# A rooted forest with 2 trees
#
# Node Data: 2 × 3 (active)
# ... etcetera

whigs |> group_by(AM) |> filter(grepl("Austin", name))
# A tbl_graph: 2 nodes and 0 edges
#
# A rooted forest with 2 trees
Error in `vec_slice()`:
! Column `type` (size 2) must match the data frame (size 261).In file slice.c at line 191.Install the winch package to get additional debugging info the next time you get this error.This is an internal error that was detected in the vctrs package.
  Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex and the full backtrace.
Backtrace:1. ├─base (local) `<fn>`(x)
  2. ├─tidygraph:::print.tbl_graph(x)
  3. │ ├─base::print(new_name_tibble(x, NULL, top, " (active)"), ...)
  4. │ └─pillar:::print.tbl(...)
  5. │   └─pillar:::print_tbl(...)
  6. │     ├─base::writeLines(...)
  7. │     ├─base::format(...)
  8. │     └─pillar:::format.tbl(...)
  9. │       └─pillar:::format_tbl(...)
 10. │         └─pillar::tbl_format_setup(...)
 11. │           ├─pillar:::tbl_format_setup_dispatch(...)
 12. │           └─pillar:::tbl_format_setup.tbl(...)
 13. │             └─pillar:::df_head(x, n)
 14. │               └─pillar:::vec_head(as.data.frame(x), n)
 15. │                 └─vctrs::vec_slice(x, seq_len(n))
 16. └─rlang:::stop_internal_c_lib(...)
 17.   └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

This is with tidygraph 1.3.1, R 4.4.0 and dplyr 1.1.4. Also confirmed on github as of today.

I'd expect filter to work as normal on grouped data, but I may be missing something....

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

1 participant