R is Arranging My Numbers Funky

Hello! I am brand new here and am searching some advice on how to potentially solve a problem. I have only been using R for about a month. I am currently trying to arrange a column that has to do with tuition fees and when I ask R to arrange the tuition fees from greatest to least, it is arranging the numbers by the first number not the whole number. So for example: it is giving me the results that 10000 is greater than 10500. It is also showing that 65000 is less than 7500. I don't know if this is exactly what is happening, but it looks like it is counting the first digit in the number, not the number as a whole. I haven't had any problems with my code up until this point. Does anybody know how to help me and why R is doing this?

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

Well looks like that was all I needed to do to fix it! Thank you so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.