0

I have data with a sample size of 1000. The data have 20 variables (1 numeric variable and 19 categorical variables). In one code, I would like to calculate the mean and SD of the numeric variable by each level of categorical variables. I want to know the average of the numeric variable by gender, for example. Then at the same time, I want to calculate this average by age group, education and other qualitative variables.

If I use the group_by (sex, age, education, ...), then I can not calculate the mean of numeric variable by each level of categorical variables separately.

How can I calculate the mean of numeric variable by all categorical variables?

M--
  • 25,431
  • 8
  • 61
  • 93
  • 1
    Welcome to SO! Please see [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). You can provide data via the output of `dput(df)`. Providing a minimal reproducible example and expected output helps increase chances of someone being able to help. – AndrewGB Jan 05 '22 at 00:45
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 12 '22 at 12:14

0 Answers0