Is there a command to add to tidyverse pipelines that does not break the flow, but produces some side effect, like printing something out. The usecase I have in mind is something like this. In case of a pipeline
data %>%
mutate(new_var = <some time consuming operation>) %>%
mutate(new_var2 = <some other time consuming operation>) %>%
...
I would like to add some command to the pipeline that would not modify the end result, but would print out some progress or the state of things. Maybe something like this:
data %>%
mutate(new_var = <some time consuming operation>) %>%
command_x(print("first operation done")) %>%
mutate(new_var2 = <some other time consuming operation>) %>%
...
Does there exist such command_x
already?
%T>%
is almost what I'm looking for, but it would be nice to have a function that returns its first argument and as a second argument would take an expression on the data given in first, like other dplyr functions do. I think I saw something like that somewhere, but might be wrong. – Gogginpipeable_command_x = function(df, other_args){command_x(other_args); return(df)}
and use that – Loyceloydtidylog
package which prints a status upon completion of each operation. – Mesonephros