且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将标准输入到R

更新时间:2023-11-18 08:22:34

如果您明确打开stdin连接,则不会发生这种情况.

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
}