【发布时间】:2023-03-27 13:25:01
【问题描述】:
我有一个看起来像 this 的数据。下面是我的代码 只需计算一些值并将输出向量绑定到 原始数据帧。
options(width=200)
args<-commandArgs(trailingOnly=FALSE)
dat <- read.table("http://dpaste.com/89376/plain/",fill=T);
problist <- c();
for (lmer in 1:10) {
meanl <- lmer;
stdevl <- (0.17*sqrt(lmer));
err_prob <- pnorm(dat$V4,mean=meanl, sd=stdevl);
problist <- cbind(problist,err_prob);
}
dat <- cbind(dat,problist)
#print(dat,row.names=F, column.names=F,justify=left)
# Why this breaks?
write(dat, file="output.txt", sep="\t",append=F);
我有几个关于上述问题的问题:
-
但是为什么上面的'write()'函数会出现这个错误。有办法解决吗?
cat(list(...), file, sep, fill, labels, append) 中的错误: 参数 1(类型 'list')不能由 'cat' 处理 调用:写 -> 猫 执行停止
-
数据框中绑定向量的名称被添加为所有 10 个新的“errprob” 列。有没有办法将它们命名为“errprob1”、“errprob2”等?
【问题讨论】:
标签: r vector dataframe writefile