any inbuilt R function here to help out

I have the dataframe with some values that are only different in salary section and first column is id. so I want to group using id as well as find the mean of salary while keeping other attributes that contains similar values as it is. It's like squeezing the data by calculating the mean of salary.

id name salary age
1 amit 5000 23
1 amit 8000 23
1 amit 5000 23
2 joseph 5600 22
2 joseph 4800 22
2 joseph 7000 22
3 nina 3600 24
3 nina 2500 24
3 nina 5000 24

Output I want :-

id name salary age
1 amit 6000 23
2 joseph 5800 22
3 nina 3700 24
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.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.