我有一些列项如下:
c(这只是一个耻辱... )#,因为它的字符这将写一个文件在你的C:\ DRIVE: / p>
sample.data< - data.frame(case1 = c(This is just a'shame'...) , case2 =这只是一个耻辱)#这里我不能让它插入双引号 write.csv(sample.data,file =C:/sample_data.csv) require(data.table) test.fread< - fread(C:/sample_data.csv) test.read.csv< - read.csv (C:/sample_data.csv)如果我阅读了 csv 数据 fread 函数(从data.table),我得到他的错误:
Bumped列79在数据行12681上键入字符,字段包含' an''。从逻辑整数或数字后面强制此列中以前读取的值到可能不是无损的字符;例如,如果'00'和'000'发生在它们现在只是'0'之前,并且可能与',,的处理不一致, ',NA,'(如果他们发生在碰撞前的这一列中)。如果这是重要的,请重新运行并将'colClasses'设置为'字符'为此列。请注意,列类型检测使用前5行,中间5行和最后5行,因此希望此消息应该非常罕见。 如果向datatable-help报告,请重新运行并包含来自verbose = TRUE的输出。如果我使用 read.csv 发生并且条目被正确读取!
问题1:如何删除字符名称中的双引号。
$ b $问题2:为什么read.csv正确读取条目,但 fread 失败? 解决方案如@Arun亲切建议, data.table 1.9.5目前在github上可能有帮助。
要安装,请按照此程序(需要Rtools):
#要安装开发版本 库(devtools) install_github(Rdatatable / data.table,build_vignettes = FALSE)它已经过测试,因此这是为了确认 data.table 的最新版本解决了双引号的问题没有问题。
有关详细信息和更新,请检查以下链接 github data.table
I have some column entries that look like this:
c("This is just a "shame"...") # since its a characterTHIS WILL WRITE A FILE ON YOUR C:\ DRIVE:
sample.data <- data.frame(case1=c("This is just a 'shame'..."), case2="This is just a shame") # here I could not make it to insert the double quotes write.csv(sample.data, file="C:/sample_data.csv") require(data.table) test.fread <- fread("C:/sample_data.csv") test.read.csv <- read.csv("C:/sample_data.csv")If I read the csv data with fread function (from data.table), I get his error:
Bumped column 79 to type character on data row 12681, field contains ' a.n."'. Coercing previously read values in this column from logical, integer or numeric back to character which may not be lossless; e.g., if '00' and '000' occurred before they will now be just '0', and there may be inconsistencies with treatment of ',,' and ',NA,' too (if they occurred in this column before the bump). If this matters please rerun and set 'colClasses' to 'character' for this column. Please note that column type detection uses the first 5 rows, the middle 5 rows and the last 5 rows, so hopefully this message should be very rare. If reporting to datatable-help, please rerun and include the output from verbose=TRUE.If I use read.csv no error occurs and the entries are read in correctly!
Question 1: How can I remove the double quotes inside the character name.
Question 2: Why read.csv reads the entries correctly but fread fails?
解决方案As @Arun kindly suggested, the data.table development version 1.9.5 currently on github may be of help here.
To install please follow this procedure (Rtools required):
# To install development version library(devtools) install_github("Rdatatable/data.table", build_vignettes = FALSE)It has been tested so this is to confirm that the newest version of data.table solves the issue with double quotes without problems.
For further details and updates check the following link github data.table
更多推荐
问题与双引号和fread函数
发布评论