0

I want to calculate the mean of Temp when Month is 6

Ozone  Solar.R  Wind  Temp  Month  Day
   41      190   7.4    67      5    1
   36      118     8    72      5    2
   12      149  12.6    74      5    3
   18      313  11.5    62      5    4
   NA       NA  14.3    56      5    5
   28       NA  14.9    66      5    6
   23      299   8.6    65      5    7
   19       99  13.8    59      5    8
    8       19  20.1    61      5    9
Jaap
  • 81,064
  • 34
  • 182
  • 193
  • There is no `Month` equals to `6` in your example. –  Jan 07 '16 at 01:52
  • 1
    Try: mean(df[df$Month == 6, ]$Temp, na.rm = TRUE) – Gopala Jan 07 '16 at 01:53
  • Sorry, I didn't realize the copied cells don't have month 6. Assume some of the cells are 6. – Manroop Singh Jan 07 '16 at 01:54
  • 1
    Here is a useful reading: http://stackoverflow.com/questions/3505701/r-grouping-functions-sapply-vs-lapply-vs-apply-vs-tapply-vs-by-vs-aggrega/7141669#7141669 –  Jan 07 '16 at 01:57

0 Answers0