T-test with two grouping variables <p>I would like to conduct t-tests for differences in age between sex (male,female), but with an additional grouping variable grp (a,b). The data is in a data frame (df). </p> <p>This gets me age by sex for the whole sample:</p> <pre><code>with(df, t.test(age~sex)) </code></pre> <p>This gets me age by group for the whole sample:</p> <pre><code>with(df, t.test(age~grp)) </code></pre> <p>I would like age by sex and group, i.e. females in a vs females in b, and males in a vs males in b.</p>