我有一个具有身高和体重的数据框人口
Height Weight
1 1.4349813 53.73766
2 1.6875582 61.83858
3 1.4952729 51.64203
etc....
我如何计算这些人中有多少个身高高于1.70,体重高于60?
I tried nrow(which(population$Height > 1.70 && population$Weight > 60))
sum(population$Height > 1.70 & population$Weight > 60)
nrow(population[population$Height > 1.70 & population$Weight > 60, ])
使用dpylr:
library(dpylr) library(magrittr) population %>% filter(Height > 1.70 & Weight > 60) %>% nrow()