dplyr :: left_join()产生意外错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了dplyr :: left_join()产生意外错误相关的知识,希望对你有一定的参考价值。

我有

> head(p)
  studie    sex n_fjernet n_sygdom
1 Group1   Male        22        1
2 Group1   Male        61        2
3 Group1 Female        50        1
4 Group1 Female        47        3
5 Group1 Female        30        1
6 Group1 Female        60        0

> head(u)
  studie alder    sex n_fjernet n_sygdom n_otte
1 Group4    59 Female        26        0      0
2 Group4    85   Male         7        1      1
3 Group4    74 Female        17        9      6
4 Group4    78   Male        13        0      0
5 Group4    41   Male        11        0      0
6 Group4    62   Male        12        0      0

我想在u$n_otte andpandp$studie==u$studieand p$sex==u$sex的所有情况下将p$n_fjernet==u$n_fjernet添加到p$n_sygdom==u$n_sygdom 895u个案例中的1485个总数。 p中所有不匹配并获得p u$n_otte的情况都应列为left_joined()

所以我写了

NA

哪个返回错误

left_join(p, u %>% distinct(studie, sex, n_fjernet, n_sygdom, .keep_all = TRUE), by = "n_otte")

我尝试了不同的Error: `by` can't contain join column `n_otte` which is missing from LHS 方法,但都返回了错误。我究竟做错了什么?

left_join()

u <- structure(list(studie = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L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2L, 2L, 2L, 2L, 
1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 
1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 
2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 
1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 
2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 
1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 
1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 
1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L
), .Label = c("Female", "Male"), class = "factor"), n_fjernet = c(26L, 
7L, 17L, 13L, 11L, 12L, 8L, 2L, 14L, 8L, 35L, 23L, 5L, 20L, 11L, 
5L, 30L, 12L, 23L, 37L, 13L, 26L, 9L, 9L, 9L, 15L, 39L, 13L, 
5L, 9L, 19L, 32L, 18L, 16L, 45L, 35L, 25L, 20L, 27L, 34L, 11L, 
44L, 20L, 48L, 92L, 6L, 29L, 12L, 26L, 37L, 30L, 54L, 32L, 39L, 
15L, 21L, 22L, 34L, 39L, 30L, 36L, 19L, 26L, 43L, 26L, 42L, 18L, 
15L, 32L, 29L, 36L, 28L, 38L, 35L, 66L, 11L, 49L, 32L, 61L, 49L, 
36L, 51L, 42L, 13L, 10L, 36L, 45L, 49L, 52L, 21L, 42L, 29L, 38L, 
28L, 37L, 47L, 33L, 50L, 19L, 45L, 23L, 29L, 31L, 59L, 60L, 32L, 
32L, 30L, 50L, 29L, 32L, 42L, 24L, 22L, 47L, 24L, 22L, 8L, 38L, 
25L, 34L, 45L, 50L, 51L, 28L, 8L, 21L, 17L, 30L, 36L, 20L, 56L, 
23L, 77L, 23L, 76L, 58L, 35L, 33L, 52L, 34L, 17L, 66L, 38L, 58L, 
16L, 58L, 44L, 22L, 42L, 17L, 33L, 9L, 31L, 15L, 46L, 31L, 32L, 
25L, 17L, 31L, 35L, 29L, 18L, 69L, 28L, 25L, 35L, 19L, 18L, 15L, 
51L, 41L, 55L, 35L, 19L, 45L, 24L, 39L, 57L, 45L, 37L, 30L, 33L, 
34L, 47L, 21L, 16L, 22L, 26L, 36L, 32L, 17L, 28L, 32L, 35L, 37L, 
30L, 32L, 29L, 41L, 18L, 26L, 32L, 30L, 17L, 35L, 17L, 27L, 27L, 
10L, 30L, 50L, 28L, 22L, 13L, 32L, 35L, 51L, 44L, 16L, 17L, 43L, 
27L, 21L, 34L, 13L, 18L, 37L, 20L, 8L, 19L, 43L, 24L, 48L, 15L, 
11L, 22L, 20L, 19L, 20L, 23L, 12L, 31L, 28L, 34L, 25L, 22L, 38L, 
28L, 26L, 30L, 45L, 50L, 39L, 22L, 41L, 14L, 60L, 35L, 10L, 29L, 
24L, 25L, 31L, 32L, 33L, 10L, 16L, 10L, 10L, 32L, 30L, 34L, 31L, 
24L, 15L, 20L, 20L, 31L, 33L, 15L, 27L, 19L, 40L, 17L, 48L, 35L, 
25L, 25L, 22L, 19L, 24L, 20L, 30L, 13L, 28L, 19L, 7L, 29L, 18L, 
41L, 11L, 42L, 35L, 24L, 16L, 29L, 39L, 28L, 32L, 16L, 31L, 30L, 
27L, 17L, 28L, 29L, 12L, 25L, 30L, 14L, 19L, 13L, 32L, 16L, 12L, 
24L, 10L, 34L, 49L, 17L, 11L, 37L, 38L, 36L, 18L, 42L, 14L, 33L, 
41L, 21L, 10L, 16L, 16L, 14L, 32L, 25L, 22L, 19L, 28L, 16L, 24L, 
28L, 29L, 34L, 27L, 23L, 33L, 23L, 57L, 30L, 16L, 13L, 20L, 42L, 
14L, 18L, 31L, 19L, 22L, 27L, 11L, 12L, 7L, 25L, 29L, 35L, 21L, 
64L, 39L, 51L, 21L, 16L, 36L, 22L, 15L, 29L, 38L, 20L, 23L, 5L, 
33L, 15L, 20L, 52L, 31L, 16L, 10L, 12L, 47L, 23L, 28L, 27L, 18L, 
24L, 34L, 45L, 24L, 43L, 28L, 34L, 20L, 26L, 17L, 41L, 25L, 38L, 
35L, 25L, 21L, 24L, 21L, 24L, 14L, 40L, 19L, 11L, 21L, 38L, 43L, 
23L, 28L, 17L, 78L, 12L, 27L, 16L, 24L, 16L, 21L, 43L, 25L, 50L, 
44L, 30L, 33L, 31L, 20L, 47L, 47L, 34L, 22L, 31L, 28L, 51L, 23L, 
45L, 30L, 34L, 32L, 39L, 41L, 25L, 15L, 19L, 14L, 41L, 40L, 49L, 
27L, 35L, 26L, 22L, 59L, 10L, 29L, 38L, 64L, 16L, 36L, 56L, 31L, 
50L, 23L, 27L, 49L, 30L, 28L, 25L, 38L, 37L, 25L, 30L, 23L, 18L, 
31L, 48L, 47L, 49L), n_sygdom = c(0L, 1L, 9L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 21L, 0L, 2L, 
0L, 0L, 0L, 2L, 1L, 1L, 0L, 0L, 2L, 2L, 0L, 0L, 7L, 1L, 0L, 0L, 
0L, 0L, 0L, 0L, 11L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 7L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 
2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 5L, 6L, 0L, 1L, 
0L, 1L, 0L, 0L, 1L, 0L, 3L, 0L, 0L, 19L, 2L, 0L, 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2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L), .Label = c("Female", "Male"), class = "factor"), n_fjernet = c(18L, 26L, 24L, 20L, 41L, 31L, 13L, 41L, 25L, 16L, 18L, 26L, 35L, 36L, 22L, 20L, 16L, 10L, 19L, 46L, 6L, 49L, 70L, 46L, 55L, 25L, 22L, 37L, 28L, 52L, 27L, 15L, 11L, 7L, 24L, 11L, 56L, 47L, 27L, 14L, 16L, 21L, 43L, 25L, 50L, 44L, 30L, 33L, 31L, 20L, 47L, 47L, 34L, 22L, 31L, 28L, 51L, 23L, 45L, 30L, 34L, 32L, 39L, 41L, 25L, 15L, 19L, 14L, 41L, 40L, 49L, 27L, 35L, 26L, 22L, 59L, 10L, 29L, 38L, 64L, 16L, 36L, 56L, 31L, 50L, 23L, 27L, 49L, 30L, 28L, 25L, 38L, 37L, 25L, 30L, 23L, 18L, 31L, 48L, 47L, 49L, 38L, 19L, 3L, 69L, 26L, 30L, 57L, 52L, 40L, 32L, 17L, 42L, 32L, 15L, 63L, 25L, 29L, 45L, 49L, 27L, 21L, 43L, 31L, 13L, 22L, 28L, 45L, 24L, 17L, 49L, 34L, 61L, 51L, 51L, 29L, 32L, 23L, 9L, 14L, 28L, 35L, 43L, 46L, 32L, 52L, 22L, 34L, 66L, 27L, 59L, 31L, 27L, 34L, 38L, 69L, 50L, 63L, 48L, 37L, 41L, 31L, 48L, 35L, 36L, 30L, 38L, 39L, 22L, 97L, 19L, 29L, 72L, 25L, 113L, 17L, 62L, 29L, 44L, 24L, 20L, 48L, 66L, 30L, 24L, 19L, 42L, 27L, 87L, 24L, 19L, 45L, 30L, 34L, 57L, 51L, 28L, 26L, 40L, 102L, 23L, 54L, 32L, 18L, 22L, 4L, 40L, 56L, 3L, 34L, 46L, 29L, 14L, 33L, 52L, 15L, 33L, 44L, 25L, 35L, 33L, 45L, 50L, 38L, 33L, 24L, 45L, 61L, 17L, 38L, 18L, 65L, 61L, 19L, 19L, 25L, 68L, 39L, 21L, 18L, 39L, 36L, 46L, 35L, 68L, 18L, 14L, 18L, 28L, 55L, 30L, 40L, 57L, 52L, 91L, 60L, 84L, 92L, 26L, 65L, 39L, 73L, 36L, 33L, 51L, 133L, 66L, 62L, 38L, 53L, 70L, 33L, 20L, 52L, 45L, 64L, 106L, 70L, 24L, 23L, 44L, 35L, 31L, 52L, 46L, 33L, 15L, 42L, 35L, 33L, 19L, 54L, 64L, 37L, 27L, 51L, 27L, 52L, 61L, 38L, 31L, 46L, 86L, 44L, 58L, 32L, 27L, 13L, 12L, 38L, 72L, 20L, 59L, 37L, 27L, 23L, 59L, 36L, 28L, 38L, 26L, 64L, 34L, 38L, 21L, 34L, 44L, 33L, 55L, 38L, 51L, 49L, 45L, 44L, 40L, 33L, 19L, 18L, 45L, 52L, 63L, 16L, 24L, 50L, 59L, 98L, 60L, 63L, 49L, 59L, 35L, 35L, 38L, 56L, 78L, 68L, 56L, 42L, 80L, 58L, 39L, 50L, 17L, 37L, 40L, 22L, 51L, 32L, 34L, 17L, 33L, 18L, 33L, 25L, 4L, 57L, 47L, 27L, 33L, 20L, 42L, 29L, 41L, 22L, 17L, 9L, 17L, 39L, 78L, 19L, 37L, 50L, 34L, 14L, 29L, 49L, 25L, 33L, 54L, 47L, 12L, 18L, 30L, 22L, 33L, 52L, 80L, 20L, 33L, 61L, 34L, 36L, 67L, 35L, 36L, 24L, 12L, 47L, 29L, 38L, 30L, 25L, 19L, 28L, 37L, 72L, 31L, 39L, 36L, 30L, 60L, 45L, 29L, 56L, 44L, 124L, 42L, 39L, 26L, 74L, 25L, 25L, 124L, 32L, 28L, 32L, 9L, 21L, 25L, 24L, 40L, 14L, 42L, 49L, 21L, 28L, 44L, 38L, 24L, 28L, 34L, 26L, 46L, 36L, 31L, 39L, 22L, 80L, 37L, 54L, 19L, 14L, 55L, 42L, 45L, 23L, 31L, 21L, 33L, 25L, 18L, 46L, 22L, 54L, 32L, 28L, 28L, 31L, 28L, 29L, 41L, 34L, 24L, 41L, 32L, 39L, 14L, 32L, 46L, 32L), n_sygdom = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0

以上是关于dplyr :: left_join()产生意外错误的主要内容,如果未能解决你的问题,请参考以下文章

dplyr left_join 小于,大于条件

使用by = c(x = y)错误在函数内执行dplyr :: left_join

使用 by=c(x=y) 错误在函数内执行 dplyr::left_join

dplyr::left_join 是不是等同于 base::merge(..., all.x=TRUE)?

使用datetime列的r dplyr :: left_join无法正确连接

dplyr 的 2 个 dfs 的 left_join 导致具有所有 NA 的 num 列