[R] how to sort a column with numbers and characters

raz barvazduck at gmail.com
Sun Jan 11 11:21:46 CET 2015


Hi,

I would like to sort a data frame by a column, the column to sort by has a
list of numbers 1:150 (a few numbers are missing so the total is 137) and
two letters "S" , "Z". How can I sort it so that first I have the numbers
in running order (1,2,3,...150) and then the letters S and Z?

the column class is "factor"

  [1] 1   10  100 101 102 104 105 106 107 108 109 11  110 111 113 114 115
116
 [19] 117 118 119 12  120 122 123 124 125 126 127 128 129 130 131 132 134
135
 [37] 136 137 138 139 140 141 142 143 144 145 146 147 148 149 15  150 16
17
 [55] 18  19  2   20  22  23  24  25  26  27  28  29  3   30  31  32  33
34
 [73] 35  36  37  38  39  4   40  41  42  43  44  45  46  47  48  5   50
51
 [91] 52  53  54  55  56  57  58  59  6   60  61  62  63  64  65  68  69
7
[109] 70  71  72  74  76  77  78  79  8   80  81  82  83  84  85  86  87
88
[127] 89  9   90  91  92  93  94  95  96  97  98  S   Z


​Thanks,

Raz​

-- 
\m/

	[[alternative HTML version deleted]]



More information about the R-help mailing list