I agree with you (I think we may be similarly aged), but there is the `magrittr::debug_pipe()` function, which can be inserted anywhere into either kind of pipe. It will call `debug()` at that point, and let you examine the current value, before passing it on to the next entry.

You can't single step through a pipe (as far as I know), but with that modification, you can see what you've got at any point.

Duncan Murdoch


On 2024-06-29 6:57 p.m., Spencer Graves wrote:
Hi, Duncan:


On 6/29/24 17:24, Duncan Murdoch wrote:

       Yes. I'm not yet facile with "|>", but I'm learning.


       Spencer Graves

There's very little to know.  This:

       x |> f() |> g()

is just a different way of writing

      g(f(x))

If f() or g() have extra arguments, just add them afterwards:

      x |> f(a = 1) |> g(b = 2)

is just

      g(f(x, a = 1), b = 2)


          Agreed. If I understand correctly, the supporters of the former think
it's easier to highlight and execute a subset of the earlier character
string, e.g., "x |> f(a = 1)" than the corresponding subset of the
latter, "f(x, a = 1)". I remain unconvinced.


          For debugging, I prefer the following:


          fx1 <- f(x, a = 1)
          g(fx1, b=2)


          Yes, "fx1" occupies storage space that the other two do not. Ir you
are writing code for an 8086, the difference in important. However, for
my work, ease of debugging is important, which is why I prefer, "fx1 <-
f(x, a = 1); g(fx1, b=2)".


          Thanks, again, for the reply.
          Spencer Graves


This isn't quite true of the magrittr pipe, but it is exactly true of
the base pipe.

Duncan Murdoch


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to