将行附加到文件
我是 R 的新手。我正在尝试使用 R 中的现有数据向文件中添加(追加)新行。问题是我的数据大约有 30000 行和 13000 列。我已经尝试使用 writeLines 函数添加一行,但生成的文件仅包含添加的行。
I'm new using R. I'm trying to add (append) new lines to a file with my existing data in R. The problem is that my data has about 30000 rows and 13000 cols. I already try to add a line with the writeLines
function but the resulting file contains only the line added.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过使用
write
函数?
Have you tried using the
write
function?write.table
、write.csv
等都具有append=
参数,该参数附加append=TRUE
和如果append=FALSE
,通常会覆盖。因此,您想要/必须使用哪一个取决于您的数据。顺便说一句,
cat()
也可用于将文本写入文件,并且还具有append=
参数。write.table
,write.csv
and others all have theappend=
argument, which appendsappend=TRUE
and usually overwrites ifappend=FALSE
. So which one you want to / have to use, depends on your data.By the way,
cat()
can also be used to write text to a file and also has theappend=
argument.您可以在附加模式下打开连接,以使用 writeLines将行附加到现有文件。
基本相同,但使用
cat
,不同之处在于每次操作都会打开和关闭文件,这会降低性能。将
cat
与连接一起使用,就像上面的writeLines
一样。在创建文件并随后追加的情况下。
You can open a connection in append mode to append lines to an existing file with
writeLines
.Basically the same but using
cat
, with the difference that the file is opened and closed on every operation, what can reduce performance.Using
cat
with a connection, like above withwriteLines
.In case of creating a file and appending subsequent.
或者
or