Pipe a value forward into a functio or call expression and return the original value instead of the result. This is useful when an expression is used for its side-effect, say plotting or printing.
Details
The tee pipe works like |>
, except the
return value is x
itself, and not the result of expr
call.
Examples
rnorm(200) |>
matrix(ncol = 2) |>
as.data.frame() |>
tee(\(x) {
ggplot(x, aes(V1, V2)) +
geom_point()
}) |>
colSums()
#> V1 V2
#> 9.197561 17.132890