The order function [🇷 for BE/BA]

posted by ElMaestro  – Denmark, 2024-03-24 18:07 (176 d 10:22 ago) – Posting: # 23918
Views: 5,225

(edited by on 2024-03-24 18:24)

Hi all,

I am experiencing something that makes me question my sanity.

Consider this code
L=c(0.000000,  5161.096198,  18218.849691,   24977.065020,  108495.506990, 
    114018.413824,  459809.038038, 8691576.342850, 9917785.333365, 6694756.609860)
str(L) 
order(L) 
data.frame(L, order(L))


I get this result:

             L order.L.
1        0.000        1
2     5161.096        2
3    18218.850        3
4    24977.065        4
5   108495.507        5
6   114018.414        6
7   459809.038        7
8  8691576.343       10
9  9917785.333        8
10 6694756.610        9


I could indeed be wrong but the order does not look right, does it? The 10'th element should be 8'th.

Tried method="radix", method="shell", but it persists. A decreasing order, same thing.
I wonder if R thinks I am ordering characters or factors in spite of the str(L) output, but even if I do ordering on
as.numeric(as.character(L))
the problem persists.
Switched to my laptop which runs Windows 11 but I get the same output.
Did I mess up something in the global environment?
What am I overlooking here?

If I call sort(L) the sort looks fine.

Many thanks for any input.
:-)

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
23,225 posts in 4,879 threads, 1,654 registered users;
44 visitors (0 registered, 44 guests [including 7 identified bots]).
Forum time: 05:30 CEST (Europe/Vienna)

The real purpose of the scientific method is to make sure
nature hasn’t misled you into thinking you know something
you actually don’t know.    Robert M. Pirsig

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5