%<>% operator do in R ?%<>% and <- ?%<>% could be useful ?The help, ?magrittr::`%<>%`, answers all your questions, if you are refering to magrittr`s compound assignment pipe-operator:
[...]
%<>%is used to update a value by first piping it into one or more rhs expressions, and then assigning the result. For example,some_object %<>% foo %>% baris equivalent tosome_object <- some_object %>% foo %>% bar. It must be the first pipe-operator in a chain, but otherwise it works like%>%.
So
library(magrittr)
set.seed(1);x <- rnorm(5)
x %<>% abs %>% sort
x
# [1] 0.1836433 0.3295078 0.6264538 0.8356286 1.5952808
is the same as
set.seed(1);x <- rnorm(5)
x <- sort(abs(x))
x
# [1] 0.1836433 0.3295078 0.6264538 0.8356286 1.5952808
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With