Re: [R] Why aren't row names in a data frame unique?

2012-03-06 Thread Jim Lemon

On 03/06/2012 06:42 PM, Ajay Askoolum wrote:

I expected the row names to be unique but a data frame appears to be able to 
hold duplicate row names. This makes me thing that there must be circumstances 
when it is necessary. However, I cannot think of any. Please enlighten me.


Hi Ajay,
An example of how you managed to do this would be helpful. I tried it:

dodo-data.frame(a=1:3,b=4:6)
dodo
  a b
1 1 4
2 2 5
3 3 6
rownames(dodo)-c(s,t,s)
Error in `row.names-.data.frame`(`*tmp*`, value = value) :
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘s’

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Why aren't row names in a data frame unique?

2012-03-06 Thread Ajay Askoolum
Jim, have a look here: 
http://www.r-bloggers.com/select-operations-on-r-data-frames/. Specifically at 
the Duplicate Row Names section towards the end of the page.




 From: Jim Lemon j...@bitwrit.com.au

Cc: R General Forum r-help@r-project.org 
Sent: Tuesday, 6 March 2012, 9:42
Subject: Re: [R] Why aren't row names in a data frame unique?

On 03/06/2012 06:42 PM, Ajay Askoolum wrote:
 I expected the row names to be unique but a data frame appears to be able to 
 hold duplicate row names. This makes me thing that there must be 
 circumstances when it is necessary. However, I cannot think of any. Please 
 enlighten me.
 
Hi Ajay,
An example of how you managed to do this would be helpful. I tried it:

dodo-data.frame(a=1:3,b=4:6)
dodo
  a b
1 1 4
2 2 5
3 3 6
rownames(dodo)-c(s,t,s)
Error in `row.names-.data.frame`(`*tmp*`, value = value) :
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘s’

Jim
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Why aren't row names in a data frame unique?

2012-03-06 Thread Berend Hasselman

On 06-03-2012, at 11:23, Ajay Askoolum wrote:

 Jim, have a look here: 
 http://www.r-bloggers.com/select-operations-on-r-data-frames/. Specifically 
 at the Duplicate Row Names section towards the end of the page.
 

Look carefully at that example.
It is NOT providing rownames for a dataframe.
It IS providing row names for a matrix.

A matrix is not equal to a dataframe.

Berend

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Why aren't row names in a data frame unique?

2012-03-06 Thread William Dunlap
S+ does allow duplicates in the row names if you ask for them
to be allowed (with data.frame(..., dup.row.names=TRUE) or
attr(df, dup.row.names) - TRUE).

They were allowed because bootstrappers were sampling the
rows of data.frames with replacement and it turned out that
a fair bit of time was being used calling make.unique() on
the row names of the sample.

There may be better solutions to that problem, but that is
why S+ allows them.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Ajay Askoolum
 Sent: Monday, March 05, 2012 11:42 PM
 To: R General Forum
 Subject: [R] Why aren't row names in a data frame unique?
 
 I expected the row names to be unique but a data frame appears to be able to 
 hold duplicate row names.
 This makes me thing that there must be circumstances when it is necessary. 
 However, I cannot think of
 any. Please enlighten me.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.