[R] strange row numbering after rbind-ing a list

Carl Witthoft carl at witthoft.com
Fri Dec 2 00:13:16 CET 2011


"Not that it really matters, but"
Can someone explain how the row numbers get assigned in the following 
sequence? It looks like something funky happens when rbind() coerces 
'bar' into a dataframe.
In either sequence of rbind below, once you get past the first two rows, 
the row numbers count normally.


Rgames> (foo<-data.frame(x=5,y=4,r=3))
   x y r
1 5 4 3
Rgames> (bar<-list(x=4,y=5,r=6))
$x
[1] 4

$y
[1] 5

$r
[1] 6

Rgames> (foobar<- rbind(foo,bar))
   x y r
1 5 4 3
2 4 5 6

Rgames> (foobar<- rbind(foobar,bar))
   x y r
1 5 4 3
2 4 5 6
3 4 5 6


Rgames> (barfoo<-rbind(bar,foo))
    x y r
2  4 5 6
21 5 4 3

Rgames> (barfoo<-rbind(barfoo,foo))
    x y r
2  4 5 6
21 5 4 3
3  5 4 3



-- 

Sent from my Cray XK6
"Pendeo-navem mei anguillae plena est."



More information about the R-help mailing list