Why factor variable is not reordering in R -
I am using an example from this page: but the code does not work:
< Code> D & LT; - Data. Frame (Team 1 = C ("Cowboy", "Legend", "Eagles", "Redskin"), Win = C (20, 13, 9, 12)) Team 1 Win 1 Cowboy 20 2 Baron 13 3 Eagles 9 4 redskin 12 & gt; D $ Team 1 [1] Cowboy Veteran Eagles Redskin Level: Cowboy Eagles Giant Redskins & gt; & Gt; D $ Team3 & lt; - Reorder (D $ Team 1, D $ Win) D Team 1 Win Team 3 1 Cowboy 20 Cowboy 2 Luminous 13 Luminous 3 Eagles 9 Eagles 4 Redskin 12 Redskin & gt; & Gt; D $ Team 3 [1] Cowboy Veteran Eagles Redskin Level: Cowboy Eagles Giant Redskins & gt; & Gt; D [Order (D $ Team 1), Team 1 Win Team 3 1 Cowboy 20 Cowboy 3 Eagles 9 Eagles 2 Giants 13 Giants 4 Redskins 12 Redskins & gt; D [Order (D $ 3 Team), Team 1 Win Team 3 1 Cowboy 20 Cowboy 3 Eagles 9 Eagles 2 Giants 13 Giants 4 Redskins 12 Redskins & gt;
Team 3 is similar to Team 1 despite the column reader command. Where is the problem Thanks for your help.
Edit:
Level (d $ Team1) [1] "cowboy" "eagles" "giant" "redskin" & gt; Level (D $ 3 team) [1] "cowboy" "eagles" "giant" "redskin" & gt;
function reorder
changes the order of the values, values No order:
& gt; Level (D $ 1 team) [1] "cowboy" "eagles" "giant" "redskin" & gt; Level (D $ 3 Team) [1] "Eagles" "Redskin" "Giant" "Cowboy"
Comments
Post a Comment