我有一个子集,我正在尝试从特定行中提取值,以便在"R"中使用分位数



子集有许多不同行的值,但出于我的目的,我只使用了一个

当前代码

male <- subset(dropped, SEXP == 2)
female <- subset(dropped, SEXP == 1)
incomeMale <- subset(male, TOTINCP > 0)
#a vector called percentIncome of all the values in the row TOTINCP from incomeMale
quantile(percentIncome, 0.05,0.10,0.95,0.90)

我想要一个TOTINCP中所有值的向量,这样我就可以使用分位数函数来获得底部5%、10%和顶部5%、10%的百分比。我试着使用nrows((,但它不接受incomeMap的子集,所以它只会给我TOTINCP中的所有值。

如果没有一个可复制的示例,很难准确理解您正在寻找什么,但下面是如何对虹膜数据集进行类似操作的概述:

#Using the iris data set, limit to one species
subset(iris, Species == "virginica")
#Get a vector of the Sepal Width for one species
subset(iris, Species == "virginica")$Sepal.Width
#Get quantiles for the Sepal Width for one species
quantile(subset(iris, Species == "virginica")$Sepal.Width, c(0.05, 0.1, 0.9, 0.95))

相关内容

最新更新