Skip to content

[BUG] mutate() fails when using base R pipe (|>) instead of magrittr pipe (%>%) #117

@LaureTomas

Description

@LaureTomas

Hi, thanks a lot for maintaining plyranges — I really enjoy using it!

I just noticed a small inconsistency when trying out the new base R pipe. With %>% everything works fine, but when I switch to |> the code breaks specifically for mutate().

Here’s a minimal example:

library(plyranges)

ir1 <- data.frame(start = 2:6, width = 3:7) %>%
  as_iranges()

ir1 %>% 
  mutate(gc = width(.))

But with the base R pipe:

ir1 <- data.frame(start = 2:6, width = 3:7) |>
  as_iranges()

ir1 |> 
  mutate(gc = width(.))
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'width': object '.' not found

I guess this might be related to how mutate() captures the . argument under %>%. Totally understand that supporting |> might introduce stricter R version requirements, but maybe there’s a workaround or at least a note in the docs to make this clear?

Thanks again for the great package!

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