Summing columns for habitat selection test

I am doing a habitat selection test using chi square and I need to lump habitats that have an expected value under 5, I've found which those are but I can't figure out how to combine the observed and proportion data for those. I need to combine value 4,6,7,8 and 9 into one value. Please help!


I do not understand your data. The Observed values seem unrelated to the Proportion values. For example the first values in each vector are 181 and 0.5005 and the last values are 206 and 0.0162. Those proportions are obviously not the proportion of the listed observations. What are they? You also want to combine observations when the expected value is less than five but all of your observations are well over five. Can you explain more about your data?

Is this the sort of thing you are looking for? I am guessing that the product of the Observed and the Proportion gives you a predicted number of counts and you want to combine all cases where the predicted number of counts is less than 5. The total number of predicted counts is preserved.


PredCounts <- Observed * Proportion
#> [1] 90.5905 44.7348  6.4032  0.0620  5.6784  1.9350  0.7035  3.6308  3.3372
#> [1] 157.0754

ObsMod <- c(Observed[1], Observed[2], Observed[3], 
            sum(Observed[4], Observed[6], Observed[7], Observed[8], Observed[9]),

PropMod <- c(Proportion[1], Proportion[2], Proportion[3], 
            sum(Proportion[4], Proportion[6], Proportion[7], Proportion[8], Proportion[9]),
PredCountsMod <- ObsMod * PropMod
#> [1] 90.5905 44.7348  6.4032 43.8730  5.6784
#> [1] 157.0754

Created on 2020-11-21 by the reprex package (v0.3.0)

The observed is the amount of times an animal was observed in a certain habitat and the proportion is the proportion that habitat takes up for the entire landscape. From these I am doing a chi square test but some values are too small and so I need to combine the row 4,6,7,8,9 so they make up an “other” habitat and I can run my chi square again.