-
Notifications
You must be signed in to change notification settings - Fork 283
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviormodify 🛠️
Description
It would appear that .else
is not evaluated when passed to modify_if()
. Unless I've missed something, I can only assume that this is a bug?
library(magrittr)
# with map_if, .else condition works as expected
purrr::map_if(1:10, ~(. < 5), ~(. = 1L), .else = ~(. = 10L)) %>% purrr::as_vector()
#> [1] 1 1 1 1 10 10 10 10 10 10
# with modify_if, .else condition does not appear to be evaluated
purrr::modify_if(1:10, ~(. < 5), ~(. = 1L), .else = ~(. = 10L))
#> [1] 1 1 1 1 5 6 7 8 9 10
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.3 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
#>
#> locale:
#> [1] LC_CTYPE=en_ZA.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_ZA.UTF-8 LC_COLLATE=en_ZA.UTF-8
#> [5] LC_MONETARY=en_ZA.UTF-8 LC_MESSAGES=en_ZA.UTF-8
#> [7] LC_PAPER=en_ZA.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_ZA.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] magrittr_1.5
#>
#> loaded via a namespace (and not attached):
#> [1] compiler_3.6.1 tools_3.6.1 htmltools_0.3.6 yaml_2.2.0
#> [5] Rcpp_1.0.2 stringi_1.4.3 rmarkdown_1.15 highr_0.8
#> [9] knitr_1.24 stringr_1.4.0 xfun_0.9 digest_0.6.20
#> [13] rlang_0.4.0 evaluate_0.14 purrr_0.3.2.9000
Created on 2019-08-29 by the reprex package (v0.3.0)
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behaviormodify 🛠️