Created
March 18, 2015 03:17
-
-
Save vsbuffalo/14f2fbdbb06176fd4f3b to your computer and use it in GitHub Desktop.
Yo dawg, I heard you like pipes, so I put a pipe in your pipe, so you can pipe streams while you pipe streams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(magrittr) | |
write.table(iris, file="iris.txt", sep="\t", row.names=FALSE, quote=FALSE) | |
plines <- function(cmd) readLines(pipe(cmd)) | |
ptabs <- function(cmd) read.delim(pipe(cmd)) | |
# just as a trivial example, process some shuffled lines using GNU shuf, sort, | |
# etc. (we could do this in R, but this is to simulate command line operations) | |
ptabs("gshuf iris.txt | sort -k5,5 -k1,1n | cut -d '\t' -f 1,2") %>% plot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So can this be done without writing the file to disk, e.g.,
ptabs(input, cmd)
? Perhaps withfifo()
?