[Rd] order function called on a data.frame?

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Mon May 18 17:31:52 CEST 2020


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
> 
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



More information about the R-devel mailing list