[R] colClasses = "logical" produces all FALSE when input is 1/0

David Kane <David Kane a296180 at agate.fmr.com
Tue Jul 23 15:33:42 CEST 2002


It seems to me that colClasses = "logical" in read.table produces incorrect results when
the input file has `1' and `0' in it. Although, it is perhaps just as likely
that I am misunderstanding the documentation.

Here is a simple example:

> file.show("test.txt")
x
1
0
1

> read.table("test.txt", header = TRUE)
  x
1 1
2 0
3 1

This result is fine.

> read.table("test.txt", header = TRUE, colClasses = "character")
  x
1 1
2 0
3 1

This one also. However, I think that this result is wrong:

> readtable("test.txt", header = TRUE, colClasses = "logical")
      x
1 FALSE
2 FALSE
3 FALSE

I would have expected:

      x
1 TRUE
2 FALSE
3 TRUE

Is there a way to get what I expected? Alas, I can't quite make out what read.table is doing in this context.

> R.version
         _                   
platform sparc-sun-solaris2.6
arch     sparc               
os       solaris2.6          
system   sparc, solaris2.6   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R                   
> 

Any suggestions would be much appreciated. 

Regards,

Dave Kane
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list