Skip to content
Prev 361756 / 398506 Next

dplyr's arrange function

On 6/15/2016 2:08 PM, Muhuri, Pradip (AHRQ/CFACT) wrote:
The problem is that you are sorting a character variable.
[1] "77.2 (1.19)" "84.5 (1.14)" "50.0 (1.33)" "88.7 (0.88)" "11.7 (1.02)"
  [6] "60.2 (1.41)" "6.1 (0.61)"  "14.6 (1.00)" "72.6 (1.82)" "73.3 (2.37)"
Notice that the 7th element is "6.1 (0.61)".  The first CHARACTER is a 
"6", so it is going to sort BEFORE the "50.0 (1.33)" (in descending 
order).  If you want the character value of line 7 to sort last, it 
would need to be "06.1 (0.61)" or " 6.1 (0.61)" (notice the leading space).

Hope this is helpful,

Dan

Daniel Nordlund
Port Townsend, WA USA