Guest User

Untitled

a guest
Jan 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. W X Y week Z
  2. w1 x1 y1 1 0
  3. w1 x1 y1 2 0.1
  4. w1 x1 y1 3 0.2
  5. w2 x2 y1 1 0.5
  6. w2 x2 y1 2 0.7
  7. w2 x2 y1 3 0.3
  8. w3 x1 y1 1 0.1
  9. w3 x1 y1 2 0.2
  10. w3 x1 y1 3 0.5
  11. w4 x2 y2 1 0.7
  12. w4 x2 y2 2 0.3
  13. w4 x2 y2 3 0.1
  14. w5 x1 y2 1 0.3
  15. w5 x1 y2 2 0.1
  16. w5 x1 y2 3 0.2
  17.  
  18. cast(foo, W + X + Y ~ ., max, value="Z")
  19.  
  20. W X Y week Z
  21. w1 x1 y1 3 0.2
  22. w2 x2 y1 2 0.7
  23. w3 x1 y1 3 0.5
  24. w4 x2 y2 1 0.7
  25. w5 x1 y2 1 0.3
  26.  
  27. library("plyr")
  28. ddply(foo, .(W, X, Y), summarise, week=week[which.max(Z)], Z=max(Z))
Add Comment
Please, Sign In to add comment