Determining if a group number of members is statistically different from another in R So, I have a large DF with a survey in which I need compare the n numbers between crosstab with categorical variables, this is a made up example.
sex <- c("male", "male", "male", "female", "male", "female", "male", 
         "female", "female", "male")

quintile <- c("first", "second", "third", "second", "fifth", "fifth", 
              "second", "fourth", "fourth", "third")

df <- data.frame(sex, quintile, stringsAsFactors = T)

So I do a crosstab:
table(df$quintile, df$sex)
        
         female male
  fifth       1    1
  first       0    1
  fourth      2    0
  second      1    2
  third       0    2

I want to know if the number of females in the first quintile is statitiscally different from the number of males, and also, if needed, if the total number of people in the first quintile (the sum of males and females) is statistically different from the the total number of people in the third quintile (or any other).
At first I thought prop.testwould make the trick, but I'm not really sure about it, and it wouldn't allow me to compare the totals anyway, at least not in the way I wanted.

I agree with Whuber's comment. Along those lines, a p.value assumes some
underlying distribution for the data before calculating the quintiles.  ,
May be we can assume to have a uniform distribution in a range of values and  no difference between males and females. From there we can generate samples, calculate the quintiles, count number of males and females, calculate the difference, and get a p-value. In this case (as Whuber stated), quintiles will change with the sample.
Overall, I feel there is some better way but we need to know more about your data
