0

I have a dataframe as such

customer_id<-c("aks123","epfk123","jfk1234","ekdm453","ddd4356","epfk123","ffg234","aks123","jfk1234","ekdm453")
customer_payment<-c("300","123","460","564","123","1245","333","1095","100","199")
df<-data.frame(customer_id,customer_payment)

There are many other columns in the df as well (like name,budget,...), these are just the ones I want to put the filter based on.

I want to store the mean value of customer_payment in a new column say avg_payments, so that I have unique trade id's and mean values of the payments corresponding to them.

ex: aks123 appears twice, so I want it to appear only once but the customer_payment for it should be the mean of the two values. For Loop is not a option as the data is very heavy.

Phil
  • 5,491
  • 3
  • 26
  • 61

0 Answers0