0

Needed an advice on how to exclude few columns in a data frame and calculate the mean value of the rest columns seperately. I could do it one by one but my wish is to know if I can do it by one code.

Age Height Weight (excluding weight and getting the mean of age and height and print them seperately)

I'm expecting for a quicker and smarter solution.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 2
    Try `colMeans(df1[-3], na.rm = TRUE)` – akrun Apr 04 '22 at 20:32
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Apr 04 '22 at 20:33
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 04 '22 at 22:17

0 Answers0