Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将每次运行 for 循环的控制台输出保存在单独的文本文件中。我正在做以下事情。
for(i in 1:x) { sink(paste0("file", i, ".txt")) ## do something }
但是一段时间后我收到了一个错误
Error in sink() : sink stack is full
最有效的方法是什么?
您必须关闭与文件的连接 per sink(),因此:
sink()
for(i in 1:x) { sink(paste0("file", i, ".txt")) ## do something sink() }