I am trying to create a dummy variable to see if the baby is born, and the other if the baby is born second. My data looks something like this.
ID MID CMOB CYRB
1 1 1 1991
2 1 7 1989
3 2 1 1985
4 2 11 1985
5 2 9 1994
6 3 4 1992
7 4 2 1992
8 4 10 1983
With ID = baby identifier, MID = mother identifier, CMOB = month of birth, and CYRB = year of birth.
For the first mannequin born, I tried using this:
Identifiers_age <- Identifiers_age %>% group_by(MPUBID)
%>% mutate(first = as.numeric(rank(CYRB) == 1))
But there seems to be no way to break ties of the rank of another column (obviously, in this case the desired column is CMOB), whenever I try to use the "ties.method" argument, it tells me the input should be a character vector.
Did I miss something?
source
share