Create a function

I have got a data.frame "Trades", which includes all trades of a year and a new table "Trades_no_duplicates", which has not duplicates based on each user (ExtId.User.ID). There I created a new column, called "Median_Risk“.

Now I would like to take from the "Trades" data frame all information from the column "Product_Risk" for each user, check what category appears the most (= median) and write this category in the column "Median_Risk" of each user (=ExtId.User.ID).

Could you help me solve this problem?

Thank you so much!

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. Also, if it is applicable, please see homework policy.

Without knowing the data layout, it's had to suggest an approach. With the right layout it's doable, though.

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