如何导出正确的TSV? [英] How to export proper TSV?

查看:1124
本文介绍了如何导出正确的TSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

短而甜:如何从R导出TSV / CSV?

Short and sweet: how can I export TSV/CSV from R?

write.table / write.csv 几乎有效:

test <- data.frame(a = 2 : 4, b = 3 : 5)
write.table(test, file='test.tsv', quote=FALSE, sep='\t')



$ more test.tsv
a   b
1   2   3
2   3   4
3   4   5

...但生成的格式与其他大多数程序的预期不同:

… but produces a format that is different from what’s expected by most other programs:

    a   b
1   2   3
2   3   4
3   4   5

- 注意不同的处理

– note the different handling of the header row.

如何导出第二个而不是第一个格式?手动指定 col.names c('',colnames(test))关于无效的参数。

How can I export the second rather than the first format? Manually specifying the col.names as c('', colnames(test)) doesn’t work – R complains about an invalid argument.

推荐答案

您可以使用 col.names = NA

write.table(test, file='test.tsv', quote=FALSE, sep='\t', col.names = NA)

这篇关于如何导出正确的TSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆