Skip to content

interesting feature

5 messages · Svetlana Eden, Brian Ripley, Douglas Bates +2 more

#
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  y
1  1 99
2 10 55
x  y
1 14 99
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  ?!
[1] 14
[1] NA
######### especially if index '11' is not functioning...
######### now I would think that the next index should be 21, BUT:
x  y
1   1 99
2  10 55
11 14 99
12 10 87
######### so what is the intuition of such indexing?
#
You are adding a row with name "1" each time.  R just adds a suffix to 
make it unique.  What you call indices are the *row names* of the data 
frame.

Suppose the row name had been "Eden".  Then "Eden1" and "Eden2" make more 
sense than your suggestions.
On Wed, 18 Feb 2004, Svetlana Eden wrote:

            
You need "11": it is a row name and not a row index.

  
    
#
Svetlana Eden <svetlana.eden at vanderbilt.edu> writes:
It's not the number 11, it is the string "11".

Row names are character strings.  In your original data frame the row
names were "1" and "2" for the first frame and "1" for the second.
The rbind function should not create a duplicate row name so it
prepended a "1" to all the names in the second frame.  That explains
the "11" and "12" in your last example.  They are simply the original
names "1" and "2" with a "1" prepended to them.
Try d["11", 1]
#
Svetlana Eden wrote:

            
What you see in the first column are the row names. The index is 1,2,3,4 
as usual.

Thomas P.
#
Hi!
On Wed, Feb 18, 2004 at 10:45:23AM -0600, Svetlana Eden wrote:
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'.
...
...
I think it all becomes clear if you try this:
foo bar
A   1  10
B   2   9
C   3   8
D   4   7
E   5   6
foo bar
A   9  99
B  10  98
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