[R] interesting feature
Philipp Pagel
p.pagel at gsf.de
Wed Feb 18 18:40:04 CET 2004
Hi!
On Wed, Feb 18, 2004 at 10:45:23AM -0600, Svetlana Eden wrote:
> > d <- rbind(d, add)
> > d
> x y
> 1 1 99
> 2 10 55
> 11 14 99
> ######### it would be more natural to index the rows: 1,2,3 instead of
> #1,2,11 ?!
What you see in the first column are row-names not indexes. Since both
data frames had a row named '1' there was a conflict which R is trying
to resolve by appending '1'.
> ######### especially if index '11' is not functioning...
...
> ######### now I would think that the next index should be 21, BUT:
...
> ######### so what is the intuition of such indexing?
I think it all becomes clear if you try this:
> a <- data.frame(foo=1:5, bar=10:6, row.names=LETTERS[1:5])
> a
foo bar
A 1 10
B 2 9
C 3 8
D 4 7
E 5 6
> b <- data.frame(foo=c(9,10), bar=c(99,98), row.names=c('A','B'))
> b
foo bar
A 9 99
B 10 98
> rbind(a,b)
foo bar
A 1 10
B 2 9
C 3 8
D 4 7
E 5 6
A1 9 99
B1 10 98
cu
Philipp
--
Dr. Philipp Pagel Tel. +49-89-3187-3675
Institute for Bioinformatics / MIPS Fax. +49-89-3187-3585
GSF - National Research Center for Environment and Health
Ingolstaedter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/~pagel
More information about the R-help
mailing list