Use of ! (or any logical operator) with %>% (magrittr) produces unexpected output

前端 未结 3 1945
猫巷女王i
猫巷女王i 2021-01-18 14:28

I have run across a situation where %>% produces very surprising output when combined with !. Consider the following code:

x <         


        
3条回答
  •  遥遥无期
    2021-01-18 14:47

    You can also use the "not" alias from the magrittr package:

    > is.na(1:20) %>% not %>% sum
    

    [1] 20

提交回复
热议问题