statistics - How to break the ties by increasing weight in R data frame? -
i need sort in reverse alphabetical order eye color, breaking ties increasing weight
, find out who's fourth male above! aggregate
have sort
function? mean break ties increasing weight
in r? can please provide answer example?
here's data frame:
jalal age sex weight eye.color hair.color 1 23 f 93.8 blue black 2 21 m 180.8 amber gray 3 22 f 196.5 hazel gray 4 22 m 256.2 amber black 5 21 m 219.6 blue gray 6 16 f 152.1 blue gray 7 21 f 183.3 gray chestnut 8 18 m 179.1 brown blond 9 15 m 206.1 blue white 10 19 m 211.6 brown blond 11 20 f 209.4 blue white 12 21 m 194.0 brown auburn 13 22 f 204.1 green black 14 21 f 157.4 hazel red 15 15 f 238.0 green gray 16 20 f 154.8 gray gray 17 16 f 245.8 gray gray 18 23 m 198.2 gray red 19 19 m 169.1 green brown 20 24 m 198.0 green gray
making small modification this answer using xtfrm
function -
sorted.jalal <- jalal[with(jalal, order(-xtfrm(eye.color), weight)), ] sorted.jalal[sorted.jalal$sex == "m", ][4,] age sex weight eye.color hair.color 8 18 m 179.1 brown blond
Comments
Post a Comment