On 12/09/2012 1:40 PM, Julio Sergio Santana wrote:
Hi, I'm trying to use pipes in R. By now, I could launch the linux command "wc" (to count words from a text), but I don't know how to capture the results, say in a vector of chars... Here is the R code I'm trying::> f <- pipe("wc", open="w") :> writeLines(c("uno dos tres", "cuatro cinco", "seis"), f) :> close(f) : 3 6 31 The result is just displayed but I couldn't put the result into a R variable. Do you have any comments on this?
The examples on the page don't show R both giving input and reading output from the same pipe. I don't think you can set it up that way; R is only one process. The usual approach is what is shown there: write to a temporary file, then pipe the results of a command that works on that file back into R. I guess you could also pipe some data into a command that writes a file, and then read that.
Duncan Murdoch ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

