DON'T MARK DUPLICATE IF YOU CAN'T SPECIFICALLY ANSWER THIS QUESTION
and I am not using lapply nor does the question match with this
size income.gap count1 count2
1 1000000 656 656
2 1000000 1443 1443
3 1000000 1232 1232
4 1000000 1036 1036
5 1000000 540 540
6 1000000 227 227
7 1000000 94 94
8 1000000 38 38
9 1000000 22 22
10 1000000 4 4
gap.data.conf <- ddply(data, ~ size, summarize,
gap = mean(income[gender == "Male"], na.rm = TRUE) - mean(income[gender == "Female"], na.rm = TRUE),
upper = -t.test(income ~ gender)$conf.int[1],
lower = -t.test(income ~ gender)$conf.int[2])
ERROR:
Error in t.test.default(x = c(35000L, 24000L, 24000L), y = 26000L) :
not enough 'y' observations
Can anyone guide me, why there are not enough y observations, although the count is equal as shown in the table above?