Skip to content

Instantly share code, notes, and snippets.

@coolbutuseless
Created July 26, 2018 13:45
Show Gist options
  • Save coolbutuseless/138e1b7a96291ee9707a7aa75aa234d6 to your computer and use it in GitHub Desktop.
Save coolbutuseless/138e1b7a96291ee9707a7aa75aa234d6 to your computer and use it in GitHub Desktop.
tweetable unpipe
#rstats #unpipe
library(rlang)
U=function(ee){A=call_args;N=call_name;C=call2;I=is_call
if(!I(ee)){return(ee)}
f=N(ee)
u=purrr::map(A(ee),U)
if(f=="%>%"){l=u[[1]]
r=u[[2]]
if(I(r)){C(N(r),!!!c(l,A(r)))}else{C(r,l)}}else{C(f,!!!u)}}
U(quote(1:3 %>% mean(na.rm=TRUE) %>% print))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment