0

我通常使用以下代码将结果写入文件中c:\...

y=rnorm(1000)
x=rep(0,length(y))
df=data.frame(rep(0,length(y)) , rep(0,length(y)))
for(i in 1:1000){
x[i]=y[i]+1
df[i,]=c(i,x[i])

print(df[i,])
flush.console()
}
write.table(df,"C:/.../results.txt")

我有时(在更复杂的情况下)有ERRORfor 循环,所以在 write.table 中我们什么都没有。我的问题是:如何在这个循环中df逐行写"c:\..."for

4

0 回答 0