sum VS. mean (what are the difference)

air <- airquality
air[c(1,3), c(3, 6)]
sum(air[c(1,3), c(3, 6)])
mean(air[c(1,3), c(3, 6)])

with these code sum function works ,but mean does not
what is the difference??

They have different implementations. sum has a method supporting data.frame inputs with all numeric-alike variables, and mean doesnt.
If you want to pass data.frame inputs with all numeric-alike variables and increase your odds of acceptance you can cast to a numeric matrix on the way.

mean(as.matrix(air[c(1,3), c(3, 6)]))
# 6

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.