Q: In an R dplyr pipeline, how can I assign some intermediate output to a temp variable for use further down the pipeline?
My approach below works. But it assigns in
This does not create an object in the global environment:
df %>% filter(b < 3) %>% { { . -> tmp } %>% mutate(b = b*2) %>% bind_rows(tmp) }
This can also be used for debugging if you use . ->> tmp instead of . -> tmp or insert this into the pipeline:
. ->> tmp
. -> tmp
{ browser(); . } %>%