Hello. I have an R program that calls gawk (GNU Awk 3.06 for Windows) from within pipe() to preprocess a large file before it is read into a data frame with read.table(). I've recently upgraded from Win98SE to WinXP, and have also upgraded from R1.5.0 to R1.6.1 over the past month or so. This program worked before the upgrade(s), but now fails. I observe the following sort of behavior with R1.6.1 under WinXP:> cat("hello\ngoodbye\n",file="textfile") > readLines("textfile")[1] "hello" "goodbye"> readLines(pipe("gawk '{print $0}' textfile"))character(0) # Note: R pauses for about 10 seconds before returning "character(0)"> readLines(pipe("echo hello"))Error in readLines(pipe("echo hello")) : cannot open the connection In addition: Warning message: cannot open cmd `echo hello'> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 6.1 year 2002 month 11 day 01 language R>gawk is in my system path, and I can successfully run it from a command window. Hence, I have the following questions: (1) Is pipe() supported in R1.6.1 under WinXP? (2) Can anyone suggest how to get pipe("gawk...") to work again? Thanks, Ronnen. P.S. E-mailed cc:s of replies posted to the list would be appreciated. -- Ronnen Levinson, Ph.D. \/ RML27 at cornell.edu scientist || http://ronnen.com Lawrence Berkeley National Lab /\ fax 425.955.1992 =====================================Take my word, the mockingbird'll sing the saddest kind o' song he knows things are wrong and he's right -- Johnny Mercer, "Blues in the Night" ===================================== -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Your example works for me on R 1.6.1 (the binary on CRAN) and Windows XP. Pipes do work differently on Windows NT and 16-bit Windows (95/98/ME), but they generally work better on NT. (XP is the marketing name for NT5.1.) On Thu, 21 Nov 2002, Ronnen Levinson wrote:> Hello. > > I have an R program that calls gawk (GNU Awk 3.06 for Windows) from > within pipe() to preprocess a large file before it is read into a data > frame with read.table(). > > I've recently upgraded from Win98SE to WinXP, and have also upgraded > from R1.5.0 to R1.6.1 over the past month or so. This program worked > before the upgrade(s), but now fails. I observe the following sort of > behavior with R1.6.1 under WinXP: > > > cat("hello\ngoodbye\n",file="textfile") > > readLines("textfile") > [1] "hello" "goodbye" > > readLines(pipe("gawk '{print $0}' textfile")) > character(0) > # Note: R pauses for about 10 seconds before returning "character(0)" > > readLines(pipe("echo hello")) > Error in readLines(pipe("echo hello")) : cannot open the connection > In addition: Warning message: > cannot open cmd `echo hello' > > version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 1 > minor 6.1 > year 2002 > month 11 > day 01 > language R > > > > gawk is in my system path, and I can successfully run it from a command > window. > > Hence, I have the following questions: > > (1) Is pipe() supported in R1.6.1 under WinXP? > (2) Can anyone suggest how to get pipe("gawk...") to work again? > > Thanks, > > Ronnen. > > P.S. E-mailed cc:s of replies posted to the list would be appreciated.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi. I have further experimented with the pipe() issue and found a workaround: putting the instructions in a batch file. It prepends two lines to the output of the pipe() instruction, but otherwise seems to work. -- Ronnen -- P.S. I am using binaries from a CRAN mirror. Uninstalling and reinstalling R1.6.1 did not affect my results. my.pipe <- function(s,batch.file="pipetemp.bat") { + cat(s, file=batch.file) + pipe(batch.file) + } > > run.gawk <- "gawk '{print $0}' textfile" > cat("hello\ngoodbye\n",file="textfile") > readLines("textfile") [1] "hello" "goodbye" > readLines(pipe(run.gawk)) character(0) > readLines(pipe("echo shalom")) Error in readLines(pipe("echo shalom")) : cannot open the connection In addition: Warning message: cannot open cmd `echo shalom' > readLines(my.pipe(run.gawk)) [1] "" [2] "D:\\My Documents\\@ARC\\@logger data>gawk '{print $0}' textfile " [3] "hello" [4] "goodbye" > readLines(my.pipe("echo shalom")) [1] "" [2] "D:\\My Documents\\@ARC\\@logger data>echo shalom " [3] "shalom" > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 1 minor 6.1 year 2002 month 11 day 01 language R > Ronnen Levinson wrote:> Hello. > > I have an R program that calls gawk (GNU Awk 3.06 for Windows) from > within pipe() to preprocess a large file before it is read into a data > frame with read.table(). > > I've recently upgraded from Win98SE to WinXP, and have also upgraded > from R1.5.0 to R1.6.1 over the past month or so. This program worked > before the upgrade(s), but now fails. I observe the following sort of > behavior with R1.6.1 under WinXP: > > > cat("hello\ngoodbye\n",file="textfile") > > readLines("textfile") > [1] "hello" "goodbye" > > readLines(pipe("gawk '{print $0}' textfile")) > character(0) > # Note: R pauses for about 10 seconds before returning "character(0)" > > readLines(pipe("echo hello")) > Error in readLines(pipe("echo hello")) : cannot open the connection > In addition: Warning message: > cannot open cmd `echo hello' > > version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 1 > minor 6.1 > year 2002 > month 11 > day 01 > language R > > > > gawk is in my system path, and I can successfully run it from a command > window. > > Hence, I have the following questions: > > (1) Is pipe() supported in R1.6.1 under WinXP? > (2) Can anyone suggest how to get pipe("gawk...") to work again? > > Thanks, > > Ronnen. > > P.S. E-mailed cc:s of replies posted to the list would be appreciated. > > -- > Ronnen Levinson, Ph.D. \/ RML27 at cornell.edu > scientist || http://ronnen.com > Lawrence Berkeley National Lab /\ fax 425.955.1992 > > =====================================> Take my word, the mockingbird'll > sing the saddest kind o' song > he knows things are wrong > and he's right > > -- Johnny Mercer, "Blues in the Night" > =====================================-- Ronnen Levinson, Ph.D. \/ RML27 at cornell.edu scientist || http://ronnen.com Lawrence Berkeley National Lab /\ fax 425.955.1992 =====================================It is no secret that organized crime in America takes in over forty billion dollars a year. This is quite a profitable sum, especially when one considers that the Mafia spends very little for office supplies. -- Woody Allen ===================================== -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._