[R] convert the contents of a date.frame to a matrix

David Winsemius dwinsemius at comcast.net
Sun May 31 18:15:44 CEST 2009


On May 31, 2009, at 12:03 PM, David Winsemius wrote:

>
> On May 31, 2009, at 10:49 AM, Hongyuan Cao wrote:
>
>> x = read.table("hongyuan_5_30_forsafe.txt", sep = "\t")
>
> > x = read.table("/Users/davidwinsemius/Downloads/ 
> hongyuan_5_30_forsafe.txt", sep = "\t")
> > str(x)
> 'data.frame':	7131 obs. of  74 variables:
> $ V1 : Factor w/ 7131 levels "","A28102_at",..: 1 934 120 122 118  
> 126 124 130 128 134 ...
> $ V2 : Factor w/ 5528 levels "","2-Sep","6-Mar",..: 1 5528 NA NA NA  
> NA NA NA NA NA ...
> $ V3 : Factor w/ 2375 levels "-1","-10","-100",..: 2374 2375 195 106  
> 499 2262 287 483 1254 143 ...
> $ V4 : Factor w/ 2326 levels "-1","-10","-100",..: 2325 2326 75 533  
> 1 1442 231 357 299 117 ...
>
> My guess (which became a conclusion after testing) was that you have  
> encountered the stringsAsFactors pitfall. (It's probably in the R  
> Inferno someplace but my favorite quote is from Terry Terneau(sic):

The default action of turning every character string into a factor is  
a plague on the S language.
    ---Terry Therneau,  from s-news, 2004


-- 
David Winsemius
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list