I have this data in a dataframe, df:
>head(df)
sx rk yr dg yd sl
1 male full 25 doctorate 35 36350
2 male full 13 doctorate 22 35350
3 male full 10 doctorate 23 28200
4 female full 7 doctorate 27 26775
5 male full 19 masters 30 33696
6 male full 16 doctorate 21 28516
...
Where sx is "sex", yd is "years after highest degree received" and sl is "salary." I want to produce a regression for sl~yd, but I want to split across sx. In other words, I want to see how males and female salaries change over their career.
Would there be a way to do this using a single lm() call? Thanks.