假设有一个作者的书籍列表,在将数据读入列表“LS”后,我尝试将其输入到文件中,输出为
> write.table(LS, "output.txt")
Error in data.frame(..., title = NULL, :
arguments imply differing number of rows: 1, 0
> write(LS, "output.txt")
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'list') cannot be handled by 'cat'
我能够使用 dput 但我希望数据的格式正确(文件中没有重复关键字的冗余)。有什么建议么?谢谢
更新 输入(头(LS,2))
list(structure(list( title = "Book 1",
authors = list(structure(c("Pooja", "Garg"),
.Names = c("forename","surname")),
structure(c("Renu", "Rastogi"),
.Names = c("forename","surname")))),
.Names = c("title", "authors")),
structure(list( title = "Book 2",
authors = list(structure(c("Barry", "Smit"), .Names = c("forename",
"surname")), structure(c("Tom", "Johnston"), .Names = c("forename",
"surname")))), .Names = c("title", "authors")))