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