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 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
left_join(x, y) x y
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
left_join(y, x) x y
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
right_join(x, y) x y
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
inner_join(x, y) x y
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
full_join(x, y) x y
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
semi_join(x, y) x y *only columns from x; no duplicate rows, even if >1 match in y
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
semi_join(y, x) x y *only columns from y; no duplicate rows, even if >1 match in x
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
anti_join(x, y) x y
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
anti_join(y, x) x y
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
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
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
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
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
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
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
Recommend
More recommend