order function called on a data.frame?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

order function called on a data.frame?

Jan Gorecki
Hi,
base::order main input arguments are defined as:

a sequence of numeric, complex, character or logical vectors, all of
the same length, or a classed R object

When passing a list or a data.frame, the resuts seems to be a bit
useless. Shouldn't that raise an error, or at least warning?

Best Regards,
Jan Gorecki

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: order function called on a data.frame?

Rui Barradas
Hello,

There is a result with lists? I am getting


order(list(letters, 1:26))
#Error in order(list(letters, 1:26)) :
#  unimplemented type 'list' in 'orderVector1'

order(data.frame(letters, 1:26))
# [1] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#[22] 48 49 50 51 52  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
#[43] 17 18 19 20 21 22 23 24 25 26


And I agree that order with data.frames should give a warning. The
result is indeed useless:

data.frame(letters, 1:26)[order(data.frame(letters, 1:26)), ]


Hope this helps,

Rui Barradas


Às 00:19 de 18/05/20, Jan Gorecki escreveu:

> Hi,
> base::order main input arguments are defined as:
>
> a sequence of numeric, complex, character or logical vectors, all of
> the same length, or a classed R object
>
> When passing a list or a data.frame, the resuts seems to be a bit
> useless. Shouldn't that raise an error, or at least warning?
>
> Best Regards,
> Jan Gorecki
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: order function called on a data.frame?

R devel mailing list
I guess we could make it do the equivalent of do.call(order, df).

On Mon, May 18, 2020 at 8:32 AM Rui Barradas <[hidden email]> wrote:

>
> Hello,
>
> There is a result with lists? I am getting
>
>
> order(list(letters, 1:26))
> #Error in order(list(letters, 1:26)) :
> #  unimplemented type 'list' in 'orderVector1'
>
> order(data.frame(letters, 1:26))
> # [1] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
> #[22] 48 49 50 51 52  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
> #[43] 17 18 19 20 21 22 23 24 25 26
>
>
> And I agree that order with data.frames should give a warning. The
> result is indeed useless:
>
> data.frame(letters, 1:26)[order(data.frame(letters, 1:26)), ]
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 00:19 de 18/05/20, Jan Gorecki escreveu:
> > Hi,
> > base::order main input arguments are defined as:
> >
> > a sequence of numeric, complex, character or logical vectors, all of
> > the same length, or a classed R object
> >
> > When passing a list or a data.frame, the resuts seems to be a bit
> > useless. Shouldn't that raise an error, or at least warning?
> >
> > Best Regards,
> > Jan Gorecki
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



--
Michael Lawrence
Senior Scientist, Data Science and Statistical Computing
Genentech, A Member of the Roche Group
Office +1 (650) 225-7760
[hidden email]

Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: order function called on a data.frame?

R devel mailing list
do.call(order, df).  ->  do.call(order, unname(df)).

While you are looking at order(), it would be nice if ';decreasing' could
be a vector the the length of list(...) so you could ask to sort some
columns in increasing order and some decreasing.  I thought I put this on
bugzilla eons ago, but perhaps not.

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, May 18, 2020 at 8:52 AM Michael Lawrence via R-devel <
[hidden email]> wrote:

> I guess we could make it do the equivalent of do.call(order, df).
>
> On Mon, May 18, 2020 at 8:32 AM Rui Barradas <[hidden email]> wrote:
> >
> > Hello,
> >
> > There is a result with lists? I am getting
> >
> >
> > order(list(letters, 1:26))
> > #Error in order(list(letters, 1:26)) :
> > #  unimplemented type 'list' in 'orderVector1'
> >
> > order(data.frame(letters, 1:26))
> > # [1] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
> > #[22] 48 49 50 51 52  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
> > #[43] 17 18 19 20 21 22 23 24 25 26
> >
> >
> > And I agree that order with data.frames should give a warning. The
> > result is indeed useless:
> >
> > data.frame(letters, 1:26)[order(data.frame(letters, 1:26)), ]
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > Às 00:19 de 18/05/20, Jan Gorecki escreveu:
> > > Hi,
> > > base::order main input arguments are defined as:
> > >
> > > a sequence of numeric, complex, character or logical vectors, all of
> > > the same length, or a classed R object
> > >
> > > When passing a list or a data.frame, the resuts seems to be a bit
> > > useless. Shouldn't that raise an error, or at least warning?
> > >
> > > Best Regards,
> > > Jan Gorecki
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> Michael Lawrence
> Senior Scientist, Data Science and Statistical Computing
> Genentech, A Member of the Roche Group
> Office +1 (650) 225-7760
> [hidden email]
>
> Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: order function called on a data.frame?

Jan Gorecki
So maybe for now just warning/error?
Should be much smaller change then those proposed by William and Michael.

Rui,
Your example of order list does raise error, but if you remove second
argument, it won't raise error anymore.

On Mon, May 18, 2020 at 5:27 PM William Dunlap via R-devel
<[hidden email]> wrote:

>
> do.call(order, df).  ->  do.call(order, unname(df)).
>
> While you are looking at order(), it would be nice if ';decreasing' could
> be a vector the the length of list(...) so you could ask to sort some
> columns in increasing order and some decreasing.  I thought I put this on
> bugzilla eons ago, but perhaps not.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
>
> On Mon, May 18, 2020 at 8:52 AM Michael Lawrence via R-devel <
> [hidden email]> wrote:
>
> > I guess we could make it do the equivalent of do.call(order, df).
> >
> > On Mon, May 18, 2020 at 8:32 AM Rui Barradas <[hidden email]> wrote:
> > >
> > > Hello,
> > >
> > > There is a result with lists? I am getting
> > >
> > >
> > > order(list(letters, 1:26))
> > > #Error in order(list(letters, 1:26)) :
> > > #  unimplemented type 'list' in 'orderVector1'
> > >
> > > order(data.frame(letters, 1:26))
> > > # [1] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
> > > #[22] 48 49 50 51 52  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
> > > #[43] 17 18 19 20 21 22 23 24 25 26
> > >
> > >
> > > And I agree that order with data.frames should give a warning. The
> > > result is indeed useless:
> > >
> > > data.frame(letters, 1:26)[order(data.frame(letters, 1:26)), ]
> > >
> > >
> > > Hope this helps,
> > >
> > > Rui Barradas
> > >
> > >
> > > Às 00:19 de 18/05/20, Jan Gorecki escreveu:
> > > > Hi,
> > > > base::order main input arguments are defined as:
> > > >
> > > > a sequence of numeric, complex, character or logical vectors, all of
> > > > the same length, or a classed R object
> > > >
> > > > When passing a list or a data.frame, the resuts seems to be a bit
> > > > useless. Shouldn't that raise an error, or at least warning?
> > > >
> > > > Best Regards,
> > > > Jan Gorecki
> > > >
> > > > ______________________________________________
> > > > [hidden email] mailing list
> > > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > > >
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
> >
> > --
> > Michael Lawrence
> > Senior Scientist, Data Science and Statistical Computing
> > Genentech, A Member of the Roche Group
> > Office +1 (650) 225-7760
> > [hidden email]
> >
> > Join Genentech on LinkedIn | Twitter | Facebook | Instagram | YouTube
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel