Piping stdin to R

后端 未结 3 2152
日久生厌
日久生厌 2020-12-01 08:12

I am having trouble piping stdin to an R script.

Here is my toy script test.R:

#!/usr/bin/env Rscript
while(length(line <- readLines(         


        
3条回答
  •  自闭症患者
    2020-12-01 08:44

    This does not happen if you explicitly open the stdin connection.

    #!/usr/bin/env Rscript
    f <- file("stdin")
    open(f)
    while(length(line <- readLines(f,n=1)) > 0) {
      write(line, stderr())
      # process line
    }
    

提交回复
热议问题