zatonovo / lambda.r

Functional programming in R
215 stars 14 forks source link

dplyr pipes + arithmetic functions causes parsing error #30

Open vixr opened 9 years ago

vixr commented 9 years ago

Using arithmetic operators in function form (e.g. *) causes an error when used in conjunction with dplyr pipes and lambda.r. See example below:

require(dplyr)
require(lambda.r)

## works
foo1(bar) %as% {
    bar * 2
}

## works
foo2(bar) %as% {
    `*`(bar, 2)
}

## works
foo3 <- function(bar) {
    bar %>% `*`(2)
}

## error - "Error in parse(text = text) ... unexpected '*'"
foo4(bar) %as% {
    bar %>% `*`(2)
}

EDIT: this seems to be specific to multiplication; addition + works