I have stumbled across a bit of an annoying problem. I am trying to perform multiple independent sample t-tests at once, grouped by a value.
To put it into an example: In 5 cities we have measured job satisfaction between males and females. For every subject we know their city, their gender, and their satisfaction score. We can do a t-test over the whole sample like this:
t.test(Score ~ Gender, paired = FALSE)
However, I want to perform a t-test for each city, to see if there is a difference in the average job satisfaction per gender per city. How do I do this?