data relations
play

Data Relations id score id sex age 2 10 1 m 19 3 18 2 m - PowerPoint PPT Presentation

Data Relations id score id sex age 2 10 1 m 19 3 18 2 m 22 4 21 3 NA NA 4 23 4 f 19 5 9 5 f 18 5 11 6 11 6 12 7 3 *_join(x, y) x y *_join(subject, exp, id) id score id sex age 2 10 1 m 19 3 18


  1. Data Relations id score id sex age 2 10 1 m 19 3 18 2 m 22 4 21 3 NA NA 4 23 4 f 19 5 9 5 f 18 5 11 6 11 6 12 7 3

  2. *_join(x, y) x y

  3. *_join(subject, exp, “id”) id score id sex age 2 10 1 m 19 3 18 2 m 22 4 21 3 NA NA 4 23 4 f 19 5 9 5 f 18 5 11 6 11 6 12 7 3

  4. left_join(x, y) x y

  5. left_join(subject, exp) id score id sex age score id sex age 2 10 1 m 19 NA 3 18 2 m 22 10 1 m 19 2 m 22 4 21 3 NA NA 18 4 23 4 f 19 21 3 NA NA 5 9 4 f 19 23 4 f 19 5 f 18 5 11 5 f 18 9 6 11 5 f 18 11 6 12 7 3

  6. left_join(y, x) x y

  7. left_join(exp, subject) id score id score sex age 2 10 2 10 m 22 id sex age 3 18 3 18 NA NA 1 m 19 4 21 4 21 f 19 2 m 22 4 23 4 23 f 19 3 NA NA 5 9 5 9 f 18 4 f 19 5 11 5 11 f 18 5 f 18 6 11 6 11 NA NA 6 12 6 12 NA NA 7 3 7 3 NA NA

  8. right_join(x, y) x y

  9. right_join(x, y) id score id sex age score id sex age 2 10 2 m 22 10 3 18 3 NA NA 18 1 m 19 2 m 22 4 21 4 f 19 21 4 23 4 f 19 23 3 NA NA 5 9 5 f 18 9 4 f 19 5 f 18 5 11 5 f 18 11 6 11 6 NA NA 11 6 12 6 NA NA 12 7 3 7 NA NA 3

  10. inner_join(x, y) x y

  11. inner_join(subject, exp) id score id sex age score id sex age 2 10 2 m 22 10 3 18 3 NA NA 18 1 m 19 2 m 22 4 21 4 f 19 21 4 23 4 f 19 23 3 NA NA 5 9 5 f 18 9 4 f 19 5 f 18 5 11 5 f 18 11 6 11 6 12 7 3

  12. full_join(x, y) x y

  13. full_join(subject, exp) id score id sex age score 1 m 19 NA id sex age 2 10 2 m 22 10 3 18 1 m 19 3 NA NA 18 2 m 22 4 21 4 f 19 21 4 23 3 NA NA 4 f 19 23 5 9 4 f 19 5 f 18 9 5 f 18 5 11 5 f 18 11 6 11 6 NA NA 11 6 12 6 NA NA 12 7 3 7 NA NA 3

  14. semi_join(x, y) x y *only columns from x; no duplicate rows, even if >1 match in y

  15. semi_join(subject, exp) id score id sex age id sex age 2 10 2 m 22 3 18 3 NA NA 1 m 19 2 m 22 4 21 4 f 19 4 23 5 f 18 3 NA NA 5 9 4 f 19 5 f 18 5 11 6 11 6 12 7 3

  16. semi_join(y, x) x y *only columns from y; no duplicate rows, even if >1 match in x

  17. semi_join(exp, subject) id score id score 2 10 2 10 id sex age 3 18 3 18 1 m 19 4 21 4 21 2 m 22 4 23 4 23 3 NA NA 5 9 5 9 4 f 19 5 11 5 11 5 f 18 6 11 6 12 7 3

  18. anti_join(x, y) x y

  19. anti_join(subject, exp) id score id sex age id sex age 2 10 1 m 19 3 18 1 m 19 2 m 22 4 21 4 23 3 NA NA 5 9 4 f 19 5 f 18 5 11 6 11 6 12 7 3

  20. anti_join(y, x) x y

  21. anti_join(exp, subject) id score id score 2 10 6 11 id sex age 3 18 6 12 1 m 19 4 21 7 3 2 m 22 4 23 3 NA NA 5 9 4 f 19 5 11 5 f 18 6 11 6 12 7 3

  22. bind_rows(subject, new_subjects) id sex age 1 m 19 id sex age id sex age 2 m 22 1 m 19 6 m 19 3 NA NA + = 2 m 22 7 m 16 4 f 19 3 NA NA 8 f 20 5 f 18 4 f 19 9 f 19 6 m 19 5 f 18 7 m 16 8 f 20 9 f 19

  23. bind_cols(subject, new_info) id sex age colour id sex age colour 1 m 19 red 1 m 19 red + = 2 m 22 orange 2 m 22 orange 3 NA NA yellow 3 NA NA yellow 4 f 19 green 4 f 19 green 5 f 18 blue 5 f 18 blue

  24. intersect(subject, new_subjects) id sex age id sex age id sex age 4 f 19 4 f 19 1 m 19 = 5 f 18 5 f 18 2 m 22 6 m 19 3 NA NA 7 m 16 4 f 19 8 f 20 5 f 18 9 f 19

  25. union(subject, new_subjects) id sex age 1 m 19 id sex age id sex age 2 m 22 4 f 19 1 m 19 3 NA NA = 5 f 18 2 m 22 4 f 19 6 m 19 3 NA NA 5 f 18 7 m 16 4 f 19 6 m 19 8 f 20 5 f 18 7 m 16 9 f 19 8 f 20 9 f 19

  26. setdiff(subject, new_subjects) id sex age id sex age id sex age 4 f 19 1 m 19 1 m 19 = 5 f 18 2 m 22 2 m 22 6 m 19 3 NA NA 3 NA NA 7 m 16 4 f 19 8 f 20 5 f 18 9 f 19

  27. setdiff(new_subjects, subject) id sex age id sex age id sex age 4 f 19 1 m 19 6 m 19 = 5 f 18 2 m 22 7 m 16 6 m 19 3 NA NA 8 f 20 7 m 16 4 f 19 9 f 19 8 f 20 5 f 18 9 f 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend