R中的Write.table循环
我想用good_geneIDs_md25_missing中指定的gene ID的名称创建1854个文件,其中包含names中指定的样本ID列表。Names是一个包含1854个obs的数据帧。在1个变量中,每行包含我的示例ID。good_geneIDs_md25_missing是一个带有1854 obs的数据帧。在1个变量中,每行包含基因ID 这是我的代码:R中的Write.table循环,r,loops,write.table,R,Loops,Write.table,我想用good_geneIDs_md25_missing中指定的gene ID的名称创建1854个文件,其中包含names中指定的样本ID列表。Names是一个包含1854个obs的数据帧。在1个变量中,每行包含我的示例ID。good_geneIDs_md25_missing是一个带有1854 obs的数据帧。在1个变量中,每行包含基因ID 这是我的代码: for(i in 1:nrow(names)){ myfile<-paste0(good_geneIDs_md25_missing
for(i in 1:nrow(names)){
myfile<-paste0(good_geneIDs_md25_missing[i,], "_", "IDs")
write.table(names[i,1],myfile, sep="\t", col.names = FALSE, row.names=FALSE,
quote = FALSE)
}
此外:警告信息:
In file(file, ifelse(append, "a", "w")) :
cannot open file 'cluster_20833::chr1:46426022-46427420_IDs': Invalid argument
好啊你能在你所在的目录中写字吗?这真的很奇怪。或者cluster_20833::chr1:46426022-46427420_IDs是目录吗?您能提供一个可复制的示例吗?我不知道数据帧是什么样子。因此,我不清楚您是否有文件扩展名。因为如果您缺少.csv或其他扩展名,这种错误在某种程度上是有意义的。但也可能是别的。谢谢你的回复。我刚刚发现问题出在哪里,原因很简单,因为R不允许创建名称包含以下内容的文件:
In file(file, ifelse(append, "a", "w")) :
cannot open file 'cluster_20833::chr1:46426022-46427420_IDs': Invalid argument