【问题标题】:Error saving data for csv using R使用 R 为 csv 保存数据时出错
【发布时间】:2016-04-19 12:16:03
【问题描述】:

使用程序 R 时,出现错误。 我写了以下代码。

txt <- readLines(file("test.csv"))

nouns <- sapply(txt, extractNoun, USE.NAMES = F)

head(unlist(nouns), 30)
tail(unlist(nouns), 30)

nouns2 <- unlist(nouns)
nouns <- Filter(function(x) {nchar(x) >= 2}, nouns2)

nouns <- gsub("지금", "", nouns)

show <-unlist(lapply(nouns,extractNoun))
showfrq<- data.frame(table(show),stringAsFactors=F)

aa<-as.matrix(showfrq)
write(aa, "test2.xls")

脚本没有错误 但是,当我查看 csv 文件时,分页有错误

我期待这个

为什么会这样? 我正在使用 R 版本 3.2.4 和 Windows 8 x64 excel 2015版

【问题讨论】:

    标签: r save export-to-csv


    【解决方案1】:

    您需要立即做两件事:将您的写入函数更改为write.csv。此外,使用文件名“test2.csv”。

    在写入 .csv 之前无需创建 aa 矩阵

    【讨论】:

      猜你喜欢
      • 2016-08-31
      • 1970-01-01
      • 2012-04-26
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多