library(tidyverse)
yourdata |>
group_by(id,name,age) |>
summarise(salary = mean(salary))
Assuming that age is fixed for id; which seems like it might be in doubt unless age is never updated over time and so is only accurate to the initial entrance of an id.