问题是如何计算数据集中150个身高以上的男性比例?
答案 0 :(得分:0)
You can use subset
to filter data based on a condition and then compute ratio of lengths of the two dataframes (original and filtered).
weight <- c(76,69,64,62,62,57,55,62,60,55)
height <- c(167,167,168,168,168,168,168,168,149,140)
data.foo <- cbind(weight, height) # Example dataset with only height and weight columns
over.150 <- subset(data.foo, height > 150) # filtered data
proportion <- nrow(over.150)/nrow(data.foo)
proportion
[1] 0.8