这是一个虚拟数据:
father<- c(1, 1, 1, 1, 1)
mother<- c(1, 1, 1, NA, NA)
children <- c(NA, NA, 2, 5, 2)
cousins <- c(NA, 5, 1, 1, 4)
dataset <- data.frame(father, mother, children, cousins)
dataset
father mother children cousins
1 1 NA NA
1 1 NA 5
1 1 2 1
1 NA 5 1
1 NA 2 4
Run Code Online (Sandbox Code Playgroud)
我想过滤这一行:
father mother children cousins
1 1 NA NA
Run Code Online (Sandbox Code Playgroud)
我可以这样做:
test <- dataset %>%
filter(father==1 & mother==1) %>%
filter (is.na(children)) %>%
filter …Run Code Online (Sandbox Code Playgroud)