5 ms·
It still annoys me that they had to invent another pipe instead of just recreate Magrittr’s in C to gain the speed it apparently lacks. And then missing out on
by napoleongl 3y ago
It still annoys me that they had to invent another pipe instead of just recreate Magrittr’s in C to gain the speed it apparently lacks. And then missing out on one of the nicer functions of magrittr…
I agree with the post that such an operator should exist., but I think it should simply be the magrittr one.
- rcthompson 3y agoI use magrittr pipes pretty much exclusively because of the extra features relative to the native pipe, but I also respect the R devs' decision not to add those extra features to the core of the language. The magrittr pipe adds additional syntax beyond the pipe itself, namely the '.' variable to refer to the piped value (essentially it's just Perl's '$_'). It's incredibly useful, but it's not particularly intuitive the way the basic pipe is.
- vasili111 3y agoAfter version 4.2 R native pipe also got place holder. It is “_” symbol. More here: https://davidbudzynski.github.io/general/2022/04/23/r-native-placeholder.html https://davidbudzynski.github.io/general/2022/04/23/r-native...
- rcthompson 3y agoYeah, but it's a single-use placeholder. AFAIK It can't do things like: x %>% set_names(., str_c("X_", names(.)) All the underscore does is let you pass the piped argument as a named argument instead of the first otherwise-unfilled argument.
- nomilk 3y agoThis talk mentions other reasons for the move away from the magrittr pipe, apparently it was very difficult to debug: https://www.youtube.com/watch?v=X_eDHNVceCU&t=1h08m33s https://www.youtube.com/watch?v=X_eDHNVceCU&t=1h08m33s
- jgalt212 3y agoall functional languages are difficult to debug. y = h(f(g(x))) where do you put the print statements or loggers?
- bradrn 3y agoIn Haskell, you put it in the pipeline: for instance, y = h (f (traceShowId (g x))) (Haskell is normally pure, but these functions from Debug.Trace are a notable exception.)
- jonnylaw 3y agoYou use a tee https://en.wikipedia.org/wiki/Tee_(command) https://en.wikipedia.org/wiki/Tee_(command)
- jgalt212 3y agoooh, that's useful. thanks.
- mtreis86 3y agoIn Common Lisp you put the print statement inline, it will return the result of the form you pass it so it doesn't change the results. If you want to know what f is returning in the form (h (f (g x))) you'd (h (print (f (g x)))) and it will print what f returns to the repl. Or use Stickers provided by Sly which sort of log things as they change. https://joaotavora.github.io/sly/#Stickers https://joaotavora.github.io/sly/#Stickers In that case you'd highlight the form starting at f, and turn a sticker on. Then run the code, sticker outputs into a window.
- hadley 3y agoThere are few differences in performance due between the base pipe and magrittr due to the work we did in 2.0.0: https://www.tidyverse.org/blog/2020/11/magrittr-2-0-is-here/ https://www.tidyverse.org/blog/2020/11/magrittr-2-0-is-here/. This release also cleaned up some edge cases so that the semantics are as similar as possible too, making it easy for folks to switch between the two.