2017-02-19 67 views
1

我有一个〜4GB +的数据集。打印一份清单的大名单

结构是

UniqueID Tags 
1   1, 37, 284 
2   1, 284 
3   234, 456, 789 
... 

我想写这样一个文件,但是它给我,因为

typeof(structure) = list 

typeof(structure$Tags) = list 

我希望问题将其写入表格中,如图所示,其中1列是UniqueID,下一列是第二列表打印出来。

当我试图写它目前使用

write.table(structure, output_file, sep="\t", row.names=FALSE,col.names=TRUE,quote=FALSE) 

我得到

Error in .External2(C_writetable, x, file, nrow(x), p, rnames, sep, eol, : 
unimplemented type 'list' in 'EncodeElement' 

这一点我敢肯定,是因为我的表内有它的列表。

编辑:我要补充,我试图做 结构$标签=膏(结构$标签,崩溃= “”)

但后来我的结果保存的格式

"c(Tag1, Tag2, ..., TagN)" 
"c(Tag1, Tag284, ...)" 
+1

您是否尝试通过'writeRDS'将其写入'rds'文件? - 看看这里:https://stat.ethz.ch/R-manual/R-patched/library/base/html/readRDS.html – Rentrop

+0

你想读取数据到另一个程序或只是保存这样它可以很容易地加载回R? – Dason

回答

0

你可以创建一个新的数据框并写入它。

tagLists <- sapply(structure$tags, paste, collapse = ",") 
df <- data.frame(unique_ids = structure$unique_ids, tags = tagLists)