我确信这很简单,但我可能会因为工作时间长而陷入困境。无论如何,这是示例:
df <- structure(list(tooth = c("UP4", "UP4", "UP4", "UP4", "UP4", "UP4",
"UP4", "UP4", "UP4", "UP4", "UP4", "UP4", "UP4", "UP4", "UP4"
), position = c("U", "U", "U", "U", "U", "U", "U", "U", "U",
"U", "U", "U", "U", "U", "U"), side = c("L", "R", "R", "R", "I",
"D", "I", "I", "D", "D", "R", NA, NA, NA, "L"), DC1 = c(5, 6,
NA, 6, 4, 7, 8, 8, 9, 12, NA, 5, 9, 5, 10), DC2 = c(4, 5, NA,
6, 6, 7, 7, 7, 8, 12, 8, 6, 7, 5, 8), DC3 = c(4, 5, 5, 5, 6,
6, 8, 9, 5, 12, 8, 7, 5, 4, 7), DC4 = c(7, 7, 6, 6, 7, 6, 10,
8, 5, 13, 7, 8, 7, 3, 8), DC5 = c(9, 9, 4, 8, 7, 5, 13, 10, 10,
7, 8, 9, 8, 5, 11), DC6 = c(10, 12, 9, 8, 9, 6, 13, 10, 11, 11,
10, 10, 8, 11, 14), DC7 = c(18, 15, 9, 11, 11, 11, 17, 8, 10,
12, 12, 15, 16, 10, 15), DC8 = c(16, 15, 15, 12, 15, 18, 18,
11, 11, 17, 14, 26, 17, 11, 19)), .Names = c("tooth", "position",
"side", "DC1", "DC2", "DC3", "DC4", "DC5", "DC6", "DC7", "DC8"
), class = "data.frame", row.names = c(1L, 2L, 3L, 4L, 5L, 7L,
8L, 10L, 11L, 12L, 16L, 19L, 23L, 24L, 26L))
如何删除在DC1
或DC2
中显示NA值的行。由于在观察中(在DC1
,DC2
或两者中都是单个NA)这一简单事实,应删除整行。所以这里的问题是运算符 OR 。
在此示例中,应删除第3行和第16行。