[R] interesting feature

Svetlana Eden svetlana.eden at vanderbilt.edu
Wed Feb 18 17:45:23 CET 2004


Hi, everybody.
This was an interesting discussion last time and it helped me a lot.

Could you please have a look at some feature and tell me
why it was designed this way
(my questions are under #########)

> x = c(1, 10)
> y = c(99, 55)
> d <- data.frame(x = x, y = y)
> d
   x  y
1  1 99
2 10 55
> add <- data.frame(x = 14, y = 99)
> add
   x  y
1 14 99
> 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  ?!
>
> d[3,1]
[1] 14
> d[11,1]
[1] NA
######### especially if index '11' is not functioning...
>
> add1 <- data.frame(x = 10, y = 87)
> d <- rbind(d, add)
######### now I would think that the next index should be 21, BUT:
> d
    x  y
1   1 99
2  10 55
11 14 99
12 10 87
######### so what is the intuition of such indexing?


-- 
Svetlana Eden        Biostatistician II            School of Medicine
                     Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list