tidyverse / magrittr

Improve the readability of R code with the pipe
https://magrittr.tidyverse.org
Other
957 stars 157 forks source link

Tee function? #135

Open hadley opened 7 years ago

hadley commented 7 years ago

i.e.

tee <- function(x, ...) {
  list(...)
  x
}

Because it looks slightly nicer to my eye? See e.g. https://github.com/hadley/testthat/issues/482

hadley commented 7 years ago

Also this just occurred to me:

safetee <- function(x, ...) {
  try(list(...))
  x
}
hadley commented 7 years ago

The puns keep coming:


finalitee <- function(x, ..., finally) {
  if (!missing(finally)) 
    on.exit(finally)

  list(...)
  x
}
smbache commented 7 years ago

Love the puns :)

Would these belong in magrittr, though, if we remove the aliases? They could also join them in the nestpas pkg, so magrittr is operators only?

smbache commented 7 years ago

Could we find useful functionality for a fatalitee too ;)

hadley commented 7 years ago

Yeah, might be better in nestpas, although these feel a bit more pipe related than the aliases.

Could also have a tee micropackage.

smbache commented 7 years ago

Maybe that could be called fatalitee :) for no apparent reason.. but the mk voice would play in many minds ...