[Rd] Bug in read.table() (PR#1477)

richard_raubertas@merck.com richard_raubertas@merck.com
Tue, 23 Apr 2002 15:55:34 +0200 (MET DST)

The following command,

temp <- read.table("c:/rfr/r/test.txt")

reads the text file "test.txt", which contains the following lines:


and produces the following result:

> temp
1 21437+0i
2 21438+0i
3     0+0i
4     0+0i
5     0+0i
6     0+0i

These "numbers" are actually sample ID's, and I expected the presence of the
hyphen would
cause temp to be character or a factor, but it ends up as complex numbers.
System info:

platform i386-pc-mingw32
arch     x86            
os       Win32          
system   x86, Win32     
major    1              
minor    4.1            
year     2002           
month    01             
day      30             
language R              

Following is a diagnosis of the problem by one of my colleagues:

> From: 	Huntsinger, Reid  
> Sent:	Monday, April 22, 2002 5:15 PM
> To:	Raubertas, Richard
> Subject:	RE: R problem
> [ ... ] This happens 
> because of the attempt to convert. The function type.convert 
> is called on columns with unspecified types; this tries to 
> convert to "logical, integer, numeric or complex" in that 
> order (first one that is successful wins). You have some ids 
> like 21428-2 which type.convert doesn't like as numeric but 
> will treat as complex. This in turn is due to R's hand-rolled 
> "strtoc" function, which returns 0+0i for something it 
> doesn't like. This is a valid value, so the conversion 
> "works", and all values are converted this way... 
> You or I should probably alert the R people. That's not very 
> good behavior.

Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.


r-devel 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-devel-request@stat.math.ethz.ch