[R] problem rbind after lapply (difference between 2.2.1 and 2.3.0)
    Gary Collins 
    collins.gs at gmail.com
       
    Wed May 10 15:35:26 CEST 2006
    
    
  
Any help on the following would be appreciated...
> R.version
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.1
year     2005
month    12
day      20
svn rev  36812
> language R
> set.seed(2)
> x=matrix(ncol=4, nrow=10)
> for(i in 1:4) x[,i]=rnorm(10)
> x=as.data.frame(x)
> x$V1=c(rep(0,5), rep(1,5))
> x
   V1          V2           V3         V4
1   0  0.41765075  2.090819205  0.7389386
2   0  0.98175278 -1.199925820  0.3189604
3   0 -0.39269536  1.589638200  1.0761644
4   0 -1.03966898  1.954651642 -0.2841577
5   0  1.78222896  0.004937777 -0.7766753
6   1 -2.31106908 -2.451706388 -0.5956605
7   1  0.87860458  0.477237303 -1.7259798
8   1  0.03580672 -0.596558169 -0.9025845
9   1  1.01282869  0.792203270 -0.5590619
10  1  0.43226515  0.289636710 -0.2465126
>  do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2))))
        min      max
0 -1.039669 1.782229
1 -2.311069 1.012829
yet with the same call on version 2.3.0, I get the following error.
> do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2))))
Error in data.frame(min = c("-1.039669", "-2.311069"), max = c("1.782229",  :
        row names contain missing values
Any clues on what has changed between the two versions? and a fix to
get around this? The actual function (min, max) within the lapply is
just an example for illustration only, the issue is the "rbinding" of
results from an lapply call. I've had a look at the changes document
packaged with 2.3.0 and found nothing...so wondering whether it's a
bug or not?
Thanks in advance.
Gary
    
    
More information about the R-help
mailing list