Skip to content
Prev 228097 / 398500 Next

invalid type error

On Jul 19, 2010, at 3:43 PM, Erik Iverson wrote:

            
And the reason that works (which I'm sure Erik knows)  is that it does  
not pass the entire row which would result in coercion of the row  
vector to the "lowest common type"  ... which in this case would be  
"character". And I think the OP might have wanted this:

 > cbind(myDF[,1,drop=FALSE], t(apply(myDF[-1],1,doit)))
    id sum_LK_positive sum_LK_negative
1 A10             1.8            -2.2
2 A20             1.8            -1.7

And the reason the  ",drop=FALSE" is needed is that otherwise the  
vector and the matrix would have been non-conformable after the column  
vector became a row vector.