R is Arranging My Numbers Funky

Welcome to the community!

Can you check whether your data is actually stored as numbers or not? In case they are stored as characters, then this is the correct lexicographical sorting. Check the outputs of is(x) and sort(as.numeric(x)), where x is the variable storing your data.

If you fail to solve your problem this way, can you please provide a REPRoducible EXample of your problem? It provides more specifics of your problem, and it helps others to understand what problem you are facing.

If you don't know how to do it, take a look at this thread:

1 Like