Skip to content
Prev 30937 / 398506 Next

index after rbind

Spencer Graves <spencer.graves at pdf.com> writes:
...and this is not a bug. Data frames should have unique rownames, so
rbind.data.frame does this internally:

    while (any(xj <- duplicated(rlabs))) rlabs[xj] <- paste(rlabs[xj],
        1:sum(xj), sep = "")

[Just for fun, have a look at 
  df1 <- data.frame(a=1:2)
  df2 <- rbind(df1, df1, df1)
  rbind(df2,df2)
]

However, it might be considered slightly unfortunate that there is no
way to turn this off, even when the next thing you're going to do is to
set new rownames.