When using mean(), sd(), etc. functions with a dataframe, I'm getting an 'argument is not numeric or logical' error.
I created a simple frame from two vectors to test functionality (i.e. to use a stat function with a data frame).
str() gives the following:
'data.frame': 195 obs. of 2 variables:
$ Births : num 10.2 35.3 46 12.9 11 ...
$ Internet: num 78.9 5.9 19.1 57.2 88 ...
Using the mean() function:
mean(frame2, na.rm=TRUE)
Gives:
Warning message: In mean.default(frame2, na.rm = TRUE) : argument is not numeric or logical: returning NA
I've seen previous advice to not use mean() with a data frame, which is fine, but not the point.
I'm going through the O'Reilly R Cookbook, and it claims you should be able to use mean() and sd() with a dataframe.
However, I can't make it work.