For循环和dplyr for循环问题

时间:2019-10-09 01:25:49

标签: r dplyr

我需要针对所计算的每种流行程度按性别进行过滤,并且我想遍历每种类型的Race以获得正确的分子和分母。但是我一直遇到同样的错误。

for(i in mylistComplications) {
  for(j in mylist2) {
    dataset <- data.use %>% select(Gender, i) %>%
      filter(Gender == j) %>% filter(get(i) == "Yes")
    Num <- nrow(dataset)
    Denomdataset <- data.use %>% select(Gender) %>% filter(Gender = j)
    Denom <- nrow(Denomdataset)
    prevalence <- (Num/Denom)*100
    print(paste("Percent of ", j, "persons with ", i, ": ", prevalence))
  }
}

Error: `Gender` (`Gender = j`) must not be named, do you need `==`?

0 个答案:

没有答案