[R] why is 9 after 10?

Federico Calboli federico.calboli at helsinki.fi
Fri Feb 12 16:13:02 CET 2016


Hi All,

I have some data, one of the columns is a bunch of numbers from 6 to 41.

table(my.data[,2])

returns

  10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37 
1761 1782 1897 1749 1907 1797 1734 1810 1913 1988 1914 1822 1951 1973 1951 1947 2067 1967 1812 2119 1999 2086 2133 2081 2165 2365 2330 2340 
  38   39   40   41    6    7    8    9 
2681 2905 3399 3941 1648 1690 1727 1668 

whereas the reasonable expectation is that the numbers from 6 to 9 would come before 10 to 41.

How do I sort this incredibly silly behaviour so that my table follows a reasonable expectation that 9 comes before 10 (and so on and so forth)?

BW

F

--
Federico Calboli
Ecological Genetics Research Unit
Department of Biosciences
PO Box 65 (Biocenter 3, Viikinkaari 1)
FIN-00014 University of Helsinki
Finland

federico.calboli at helsinki.fi



More information about the R-help mailing list