Skip to content
Back to formatted view

Raw Message

Message-ID: <F794A899-27CC-4C56-A90F-062FEC79831A@comcast.net>
Date: 2018-05-23T03:06:39Z
From: David Winsemius
Subject: find the permutation function of a sorting
In-Reply-To: <CABcx46D6Prk-OE4DwfWjdYPyzB+q3Wbfhdp=uDxojDs2_XhuJA@mail.gmail.com>

> On May 22, 2018, at 10:57 PM, John <miaojpm at gmail.com> wrote:
> 
> Thanks, David. 
> I got the answer from the web. 
> Is there any easy way to permute a set (e.g., a set of characters) by the permutation it returns? Thanks,
> 
> 
> > x <- c(10,7,4,3,8,2)
> > sort(x, index.return=TRUE)
> $x
> [1]  2  3  4  7  8 10
> 
> $ix
> [1] 6 4 3 2 5 1
> 

I don't understand what is being requested. The $ix value is the same as the one returned `by order`.

David.


> 2018-05-23 10:49 GMT+08:00 David Winsemius <dwinsemius at comcast.net>:
> 
> 
> > On May 22, 2018, at 10:06 PM, John <miaojpm at gmail.com> wrote:
> > 
> > Hi,
> > 
> >   Is there any way to find the permutation function of the sorting and to
> > apply the function (or its inverse) elsewhere?
> > 
> >   For example, the following permutation function from the sorting in the
> > matrix form is
> > c(1,2,3), c(2,1,3)
> > 
> >> sort(c("bc","ac","dd"))
> > [1] "ac" "bc" "dd"
> > 
> 
> I think you are asking for the `order` function.
> 
> >   I try to find it in the permutations/permute package, but I can't find it
> > 
> > John
> > 
> >       [[alternative HTML version deleted]]
> 
>