[R] Finding Source of Error Message of 'Non-Unique Index Entries'

David Winsemius dwinsemius at comcast.net
Tue Jan 3 20:56:16 CET 2012


Maybe we need to backtrack a bit. You originally were complaining  
about an error that said you had duplicated index entries as you  
attempted to make a zoo object. I assumed, incorrectly it now  
appears,  that you understood that an index in a zoo object was a  
vector. You now seem to be admitting that you were trying to use an  
entire dataframe as your index. As the acronym goes, ...  DDT.


On Jan 3, 2012, at 1:53 PM, Rich Shepard wrote:

> On Tue, 3 Jan 2012, David Winsemius wrote:
>
>> That's rather unconvincing. What does this show:
>> burns.tds[ !duplicated(burns.tds) ]
>
>  I saw that in the help page but assumed it was the opposite of  
> duplicated;
> apparently not.
>
> burns.tds[ !duplicated(burns.tds) ]
> Error in .data.frame(burns.tds, !duplicated(burns.tds)) :
>  undefined columns selected

Right. If you had said it was a dataframe, I would have suggested:

burns.tds[ !duplicated(burns.tds) ,  ]

But that would only identify entire duplicated rows; it would  not  
cure the misguided notion of creating a zoo-index from a dataframe.

>
>  burns.tds was generated by
>
> burns.tds <- subset(chemdata, stream == 'BurnsCrk', select = c(site,
> sampdate, param == 'TDS', quant), drop = T)
>
> and has this structure
>
> 'data.frame':	2472 obs. of  3 variables:
> $ site    : Factor w/ 137 levels "BC-0.5","BC-1",..: 5 5 5 5 5 5 5  
> 5 ...
> $ sampdate: Factor w/ 1056 levels "1978-03-28","1978-04-11",..: 155  
> 156 158
> 161 163 164 172 175 177 309 ...
> $ quant   : num  0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 8.08 ...
>
>  Because the data frame chemdata came from a relational table with a
> primary key of (site, sampdate, param) I am having trouble  
> understanding
> where duplicate rows could have originated.

You still have not really described what your are trying to do ... or  
with what data you are trying to do it with. You might want to think  
about taking that sampdate which is now a factor and turinging it into  
a data object which would then satisfy the requirements of an index  
for a zoo object. The second letter in "zoo" stands for "ordered" and  
factors have no order.
>

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list