Why is the following code trying to execute the alias%>% of the magrittr character not working?

Why is the following code not working?

require(dplyr)
`%test%`<- `%>%`
mtcars %test% head
#Error in pipes[[i]] : subscript out of bounds

When the following is done:

a <- function(x) x^2
a(4)
#[1] 16
b <- a
b(4)
#[1] 16

Why is this happening and what needs to be done to make it work?

+4
source share
1 answer

As alexis_laz points out, it has to magrittr:::is_pipedo with explicitly checking for %>%in your expression, and not detecting it and the subsequent logic falling apart %>%because of this.

But why do %>%you need to explicitly search (self or other) %>%in the call?

- %>% , . , %>% , a %>% b %>% c c(b(a)), eval'd ( , b(a) %>% c).

, , - , . .

+7

Source: https://habr.com/ru/post/1614660/


All Articles