Skip to content

Add function not behaving correctly when being fed an expression #265

Description

@victorfeagins

I like to use magrittr aliases for arithmetic operations to get the Order of operations correct without playing around with parathesis when working with complicated formulas. Though today I noticed the results are sensitive to how results are feed into the function and it behaves unexpectedly wrong.

library(magrittr)
test <- 1

test_nopipe <- test^2/2 + test^2/2

test_expressions <- test^2/2 %>% 
  add(test^2/2)

step <- test^2/2

test_asvariable <- step %>% 
  add(step)


test^2
#> [1] 1
test_expressions #Wrong
#> [1] 0.4
test_nopipe
#> [1] 1
test_asvariable
#> [1] 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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