0

The subset has many values different rows but for my purpose, I only use one

Current Code

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)

I want a vector of all the values in TOTINCP so that I can use the quantiles function to get the percentages of the bottom 5%, 10% and top 5%, 10% . I tried using nrows() but it doesn't take in the subset of incomeMale so it would just be giving me all the values in TOTINCP.

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Dec 01 '21 at 20:36

1 Answers1

0

It's difficult to understand exactly what you're looking for without a reproducible example, but here's an outline of how to do something similar with the iris data set:

#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))
Jordo82
  • 796
  • 4
  • 14