I have a (for me) rather complicated question and don't really know how to describe it. Sorry if there already is a solution to this I didn't find!
Let's say I have a dataframe with the amount of years people stayed at their parents home, their mothers education status and sample year.
df <- data.frame(years = c(3,2,3,3,2,3,1,3,1,3),
edu = c(3,3,2,1,2,1,3,2,1,2),
sample = c(2000, 2005, 2000,2005, 2000, 2005, 2000, 2005, 2000, 2005))
I want to make a crosstable between the percentage of people staying with their parents for 3 years and their mothers education status, but sorted by sample year, so that in the end I have a table that can show period-effects but is still controlling for education status.
I tried and failed using various aggregate, filter and if_any ideas, but they all failed in (at least) one regard.
Any help would be appreciated!