gpt4 book ai didi

r - 将向量写入垂直列中的文本文件

转载 作者:行者123 更新时间:2023-12-04 09:30:44 24 4
gpt4 key购买 nike

我有一个单词列表,我想将其输出到文本文件。例如:

words <- c("a", "and", "book", "cat", "car", "door", "donkey", "ogre", "princess", "rain")
write(words, file = "test.out", ncolumns = 5, sep = "\t")

这行得通,但它给了我按水平顺序排列的单词:a, and, book, cat, car 在第一排,然后是门,驴,食人魔,公主,雨在第二排。我希望订单向下列。 (显然,实际的列表比这个例子长得多)。

有什么办法吗?

谢谢。

最佳答案

解决方案在这里:Write lines of text to a file in R .基于它:

fileConn <- file("test.out")    
writeLines(c("a", "and", "book", "cat", "car", "door", "donkey", "ogre", "princess", "rain"), fileConn)
close(fileConn)

关于r - 将向量写入垂直列中的文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43712246/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com