creating grouped mean variable
Posted: Fri Oct 03, 2025 12:49 pm
Hi,
I would like to have a functionality similar to ave in base R to create a grouped mean variable. I have a dataset with a continuous variable x and group. Now I want to create a new variable where all observations in a particular group have the same mean. How to do?
I would like to have a functionality similar to ave in base R to create a grouped mean variable. I have a dataset with a continuous variable x and group. Now I want to create a new variable where all observations in a particular group have the same mean. How to do?