[R] Help with .csv file reading !

David Winsemius dwinsemius at comcast.net
Thu Jan 19 15:46:54 CET 2012


On Jan 19, 2012, at 9:34 AM, David Winsemius wrote:

>
> On Jan 19, 2012, at 9:22 AM, aaurouss wrote:
>
>> Hello,
>>
>> Here's my problem :
>>
>> I have a csv file which I have to read with read.table() function (or
>> read.csv). The file has about 60000 lines whose data are written  
>> this way:
>> character;character;character;character
>>
>> 14/10/2010 13:10;0;49;0;49;
>>
>> 14/10/2010 13:20;0;49;0;49;
>>
>> 14/10/2010 13:30;0;49;0;49;
>>
>>
>> I tried to use the function this way:    read.csv("file.csv",sep =
>> ";",colClasses = "character", fill="TRUE",as.is=TRUE,h=FALSE).
>
> If you are expecting 5 columns as this would suggest then your  
> colClasses argument needs to be rep("character", 5)

Actually that is not correct, ... to my surprise. I didn't realize  
that colClasses would get automagically repeated.

And the other error would be thinking that "TRUE" is the same as TRUE.  
In this case it would appear that not all truths are self-evident.

I try to avoid partial spellings of arguments. I predict that  
continuing to use "h=FALSE" will get you into trouble in the long run.

>
>>
>> Here's what I get as an error:
>> Error in fill && length(col.names) > cols :
>> type 'x' incorrect in 'x && y'
>>
>> I can't find any set of options with any of the read functions that  
>> work.
>
> You need to read the read.table documentation again, ... and  
> again, ...  and again.
>
> -- 
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list