From p.dalgaard at biostat.ku.dk  Wed Sep 15 18:00:27 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed Sep 15 18:01:23 2004
Subject: [Rd] Bug in merge() in R-2.0.0 alpha
In-Reply-To: <414858D5.7060308@statistik.uni-dortmund.de>
References: <414858D5.7060308@statistik.uni-dortmund.de>
Message-ID: <x2fz5j4j50.fsf@biostat.ku.dk>

Uwe Ligges <ligges@statistik.uni-dortmund.de> writes:

> In some cases, merge() has a problem in R-2.0.0 alpha (2004-09-14):
> 
>    x <- structure(c("a", "b", "2", "0.2-26", "O", "O"), .Dim = c(2, 3),
>      .Dimnames = list(c("1", "2"), c("P", "V", "2")))
> 
>    y <- structure(c("a", "b", "2", "0.2-25", "O", "O"), .Dim = c(2, 3),
>      .Dimnames = list(c("1", "2"), c("P", "V", "1")))
> 
>    merge(x, y, all.y=TRUE)
> 
> Error in "[<-"(`*tmp*`, ri, value = NULL) :
>          incompatible types
> 
> 
> Looks like the NA handling has changed anywhere.

Names handling, more likely:

> v <- structure(list("2" = NA), .Names = "2", class = "data.frame", row.names = "2")
> u <- structure(list("2" = structure(1, .Names = "1", .Label = "O", class = "factor")), .Names = "2", class = "data.frame", row.names = "1")
> uu <- structure(list("2" = structure(1,  .Label = "O", class = "factor")), .Names = "2", class = "data.frame", row.names = "1")
> rbind(v,u)
     2
2 <NA>
1    O
> rbind(v,uu)
     2
2 <NA>
1    O
> rbind(u,v)
Error during wrapup: incompatible types
> rbind(uu,v)
     2
1    O
2 <NA>


(Notice that the only difference between u and uu is the .Names bit)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Bug in merge() in R-2.0.0 alpha
Peter Dalgaard