Upgrade to Pro — share decks privately, control downloads, hide ads and more …

useR-2019-rray.pdf

Davis Vaughan
July 05, 2019
1.2k

 useR-2019-rray.pdf

Davis Vaughan

July 05, 2019
Tweet

Transcript

  1. + = peanut plain blue red green 12 9 10

    15 6 8 blue red green 2 3 1
  2. peanut plain blue red green 14 11 13 18 7

    9 + = blue red green 2 3 1 peanut plain blue red green 12 9 10 15 6 8
  3. bag bag[,1:2] peanut plain blue red green 12 9 10

    15 6 8 red 15 8 green peanut plain 10 6
  4. bag bag[,1:2] peanut plain blue red green 12 9 10

    15 6 8 red 15 8 green peanut plain 10 6 6 8 12 10 blue 15 pb green 9 plain red ? bag bag[,1]
  5. 6 8 12 10 blue 15 peanut green 9 plain

    red peanut plain 10 ] [ 15 bag bag[,1] bag bag[,1:2] peanut plain blue red green 12 9 10 15 6 8 red 15 8 green peanut plain 10 6
  6. 6 8 12 10 blue 15 peanut green 9 plain

    red plain 10 peanut green 15 bag bag[, 1, drop = FALSE] bag bag[,1:2] peanut plain blue red green 12 9 10 15 6 8 red 15 8 green peanut plain 10 6
  7. bag1 bag2 bag1 bag2 6 8 12 10 blue 15

    peanut green 9 plain red bags 10 green plain 15 peanut 3 13 plain peanut bags[, 1, , drop = FALSE] 5 6 15 3 13 peanut 11 plain
  8. bag1 bag2 bag1 bag2 6 8 12 10 blue 15

    peanut green 9 plain red bags 10 green plain 15 peanut 3 13 plain peanut bags[, 1, , drop = FALSE] 5 6 15 3 13 peanut 11 plain This is a (2, 3, 2) 3D array
  9. bag1 bag2 bag1 bag2 6 8 12 10 blue 15

    peanut green 9 plain red bags 10 green plain 15 peanut 3 13 plain peanut bags[, 1, , drop = FALSE] 5 6 15 3 13 peanut 11 plain
  10. bag1 bag2 bag1 bag2 6 8 12 10 blue 15

    peanut green 9 plain red 5 6 15 3 13 peanut 11 plain bags 10 green plain 15 peanut 3 13 plain peanut bags[, 1, , drop = FALSE] bag[, 1, drop = FALSE]
  11. Create an rray library(rray) bag #> green red blue #>

    peanut 15 8 12 #> plain 10 6 9 bag_rray <- as_rray(bag) bag_rray #> <rray<dbl>[,3][2]> #> green red blue #> peanut 15 8 12 #> plain 10 6 9
  12. bag1 bag2 bag1 bag2 6 8 12 10 blue 15

    peanut green 9 plain red bags_rray 10 green plain 15 peanut 3 13 plain peanut bags_rray[, 1] bag1 bag2 6 red peanut 8 plain 10 15 green 3 plain 6 13 5 peanut bags_rray[, 1:2] 6 8 12 10 blue 15 peanut green 9 plain red 15 6 10 plain 8 peanut red green bag_rray bag_rray[, 1:2] peanut 10 15 green plain bag_rray[, 1] 5 6 15 3 13 peanut 11 plain
  13. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + blue red green 2 3 1 extra (1, 3) 5 6 15 3 13 peanut 11 plain = Error: non-conformable arrays
  14. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + extra (2, 3, 2) = bag1 bag2 7 9 14 13 blue 18 peanut green 11 plain red (2, 3, 2) 5 6 15 3 13 peanut 11 plain 6 7 17 6 16 peanut 13 plain 3 red 3 green blue 2 1 1 2 2 1 2 3 1 3
  15. # row # col # frame bags 2 3 2

    extra 1 3 1 ? ? ?
  16. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + extra (1, 3, 1) = 5 6 15 3 13 peanut 11 plain blue green red 3 1 2 bag1 bag2 6 8 12 10 blue 15 peanut green 9 plain red bags (2, 3, 2) + blue red green 2 3 1 extra (1, 3) = 5 6 15 3 13 peanut 11 plain
  17. # row # col # frame bags 2 3 2

    extra 1 3 1 ? ? ?
  18. # row # col # frame bags 2 3 2

    extra 1 2 3 1 ? 2 ? ?
  19. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + extra (2, 3, 1) = 5 6 15 3 13 peanut 11 plain 2 1 3 blue green red 3 1 2 bag1 bag2 6 8 12 10 blue 15 peanut green 9 plain red bags (2, 3, 2) + extra (1, 3, 1) = 5 6 15 3 13 peanut 11 plain blue green red 3 1 2
  20. # row # col # frame bags 2 3 2

    extra 1 2 3 1 ? 2 ? ?
  21. # row # col # frame bags 2 3 2

    extra 1 2 3 1 ? 2 ? 3 ?
  22. # row # col # frame bags 2 3 2

    extra 1 2 3 1 2 ? 2 ? 3 ? 2
  23. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + extra (2, 3, 2) = bag1 bag2 7 9 14 13 blue 18 peanut green 11 plain red (2, 3, 2) 5 6 15 3 13 peanut 11 plain 6 7 17 6 16 peanut 13 plain 3 red 3 green blue 2 1 1 2 2 1 2 3 1 3
  24. bag1 bag2 6 8 12 10 blue 15 peanut green

    9 plain red bags (2, 3, 2) + extra (2, 3, 2) = bag1 bag2 7 9 14 13 blue 18 peanut green 11 plain red (2, 3, 2) 5 6 15 3 13 peanut 11 plain 6 7 17 6 16 peanut 13 plain 3 red 3 green blue 2 1 1 2 2 1 2 3 1 3
  25. rray broadcasts bag #> green red blue #> peanut 15

    8 12 #> plain 10 6 9 extra #> green red blue #> [1,] 3 1 2 bag + extra #> Error in bag + extra: non-conformable arrays bag_rray + extra #> <rray<dbl>[,3][2]> #> green red blue #> peanut 18 9 14 #> plain 13 7 11
  26. rray as a toolkit rray_bind() rray_duplicate_any() rray_expand_dims() rray_broadcast() rray_flip() rray_max()

    rray_sum() rray_mean() rray_reshape() rray_rotate() rray_split() rray_tile() rray_unique() ...
  27. rray as a toolkit rray_bind() rray_duplicate_any() rray_expand_dims() rray_broadcast() rray_flip() rray_max()

    rray_sum() rray_mean() rray_reshape() rray_rotate() rray_split() rray_tile() rray_unique() ...
  28. rray as a toolkit rray_bind() rray_duplicate_any() rray_expand_dims() rray_broadcast() rray_flip() rray_max()

    rray_sum() rray_mean() rray_reshape() rray_rotate() rray_split() rray_tile() rray_unique() ...
  29. 6 8 12 10 blue 15 peanut green 9 plain

    red Compute proportions 1) Overall 2) By filling 3) By color
  30. 0.43 0.57 0.57 0.40 blue 0.60 peanut green 0.43 plain

    red 0.24 0.23 0.34 0.40 blue 0.43 peanut green 0.36 plain red 0.10 0.13 0.20 0.17 blue 0.25 peanut green 0.15 plain red 6 8 12 10 blue 15 peanut green 9 plain red 6 8 12 10 blue 15 peanut green 9 plain red 6 8 12 10 blue 15 peanut green 9 plain red bag / sum(bag) sweep(bag, 1, apply(bag, 1, sum), "/") sweep(bag, 2, apply(bag, 2, sum), "/") Overall By Filling By Color
  31. bag / rray_sum(bag) bag / rray_sum(bag, axes = 2) bag

    / rray_sum(bag, axes = 1) Overall By Filling By Color 6 8 12 10 blue 15 peanut green 9 plain red 6 8 12 10 blue 15 peanut green 9 plain red 6 8 12 10 blue 15 peanut green 9 plain red 0.43 0.57 0.57 0.40 blue 0.60 peanut green 0.43 plain red 0.24 0.23 0.34 0.40 blue 0.43 peanut green 0.36 plain red 0.10 0.13 0.20 0.17 blue 0.25 peanut green 0.15 plain red