You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[R-Forge #5323] fread: colClasses does not convert to non-builtin types #491
Submitted by: James Sams; Assigned to: Nobody; R-Forge link
If I set a column to numeric, character, etc., the conversion works as expected. However, if I set it to a user created class, it seems like fread gets confused. It recognises that the column is supposed to be converted, but doesn't do the conversion.
The message generated by fread in this situation (sample code attached) is:
# Detected eol as \n only (no \r afterwards), the UNIX and Mac standard.# Using line 2 to detect sep (the last non blank line in the first 'autostart') ... none found (see ?fread). # Deducing this is a single column input. Otherwise, please specify 'sep' manually.# First row with 1 fields occurs on line 1 (either column names or first row of data)# All the fields on line 1 are character fields. Treating as the column names.# Count of eol after first data row: 2# Subtracted 1 for last eol and any trailing empty lines, leaving 1 data rows# Type codes: 0 (first 5 rows)# Column 1 ('date') was detected as type 'integer' but bumped to 'numeric' as requested by colClasses# 0.000s ( 0%) Memory map (rerun may be quicker)# 0.000s ( 0%) sep and header detection# 0.000s ( 0%) Count rows (wc -l)# 0.000s ( 0%) Column type detection (first, middle and last 5 rows)# 0.000s ( 0%) Allocation of 1x1 result (xMB) in RAM# 0.000s ( 0%) Reading data# 0.000s ( 0%) Allocation for type bumps (if any), including gc time if triggered# 0.000s ( 0%) Coercing data already read in type bumps (if any)# 0.000s ( 0%) Changing na.strings to NA# 0.000s Total
Strange issue IMHO. It is normal that fread supports only built-in simple types (and parsing is in C, so we don't know anything about user supplied classes). If somebody need to convert/coerce types he should do it himself using := operator.
Activity
dselivanov commentedon Feb 4, 2016
Strange issue IMHO. It is normal that
freadsupports only built-in simple types (and parsing is in C, so we don't know anything about user supplied classes). If somebody need to convert/coerce types he should do it himself using:=operator.randomizedthinking commentedon Feb 28, 2016
I encountered the similar issue that fread doesn't recognize other data types. Here is a code nugget:
The type of
tmp$V2is character but rather thanmyDate. Meanwhile,read.csvfunction can do the conversion correctly.arunsrinivasan commentedon Feb 28, 2016
This issue is open only to implement derived inbuilt classes (parsing date, POSIXct etc.).
freadwill not understand all custom classes.