Thanks. It makes sense.
Jeff Newmiller 于2018年11月8日周四 下午8:05写道:
> The duplicated function returns TRUE for rows that have already
> appeared... exactly one of the rows is not represented in the output of
> duplicated. For the intended purpose of removing duplicates this behavior
> is ideal. I
The duplicated function returns TRUE for rows that have already appeared...
exactly one of the rows is not represented in the output of duplicated. For the
intended purpose of removing duplicates this behavior is ideal. I have no idea
what your intended purpose is, since every row has
One way, rather clumsy, is to convert your data.frame in a character vector
or list. via an invertible tranformation, and use match on it. E.g.,
> tmp <- do.call(paste, c(list(sep="\001"), unname(C))) # convert to
character
> # or tmp <- split(C, seq_len(nrow(C))) # convert to list of its rows
>
Thanks to all the reply. I will try to use plain text in the future.
One question regarding using "which( ! duplicated( m, MARGIN=1 ) )".
This seems to return the fist row indices corresponding to the distinct
rows but it does not give all the row indices
corresponding to each of the distinct
Yes -- much better than mine. I didn't know about the MARGIN argument of
duplicated().
-- Bert
On Wed, Nov 7, 2018 at 10:32 PM Jeff Newmiller
wrote:
> Perhaps
>
> which( ! duplicated( m, MARGIN=1 ) )
>
> ? (untested)
>
> On November 7, 2018 9:20:57 PM PST, Bert Gunter
> wrote:
> >A mess --
Perhaps
which( ! duplicated( m, MARGIN=1 ) )
? (untested)
On November 7, 2018 9:20:57 PM PST, Bert Gunter wrote:
>A mess -- due to your continued use of html formatting.
>
>But something like this may do what you want (hard to tell with the
>mess):
>
>> m <- matrix(1:16,nrow=8)[rep(1:8,2),]
>>
A mess -- due to your continued use of html formatting.
But something like this may do what you want (hard to tell with the mess):
> m <- matrix(1:16,nrow=8)[rep(1:8,2),]
> m
[,1] [,2]
[1,]19
[2,]2 10
[3,]3 11
[4,]4 12
[5,]5 13
[6,]6 14
[7,]
Hi all,
I use the following example to illustrate my question. As you can see,
in matrix C some rows are repeated and I would like to find the indices of
the rows corresponding to each of the distinct rows.
For example, for the row c(1,9), I have used the "which" function to
identify the row
8 matches
Mail list logo