r – group_by and mutate based on string value

I am attempting to group_by and filter a table, and eventually, mutate a new column based on a specific string value.
The table I have looks like this-

id value
1 age
1
2 gender
2 gender
2
3

And what i’m attempting to do here is to mutate a new column that populates “1” based on the specific value, but for all the same IDs. This was i’m able to filter out all the id’s that have a specific value. Say that value is “gender”, I would like the new column values and table to be-

id value result
1 age
1
2 gender 1
2 gender 1
2 1
3

The way I have attempted this in the past is that I’m able to mutate a new column and do a group_by if there is n_distinct == 1, for example

new_table <- table %>% group_by(id) %>% mutate(result = if_else(value=="gender" & n_distinct(value)>1,"1",""))

But this wont work since id 1 also has n_distinct(value)>1.
Also open to completely changing my method for something that works,
Please help.