I have a data frame with two columns. When I try to calculate mean
, I get this message:
[1] NA
Warning message:
In mean.default(results) : argument is not numeric or logical: returning NA`
where ‘results’ is my data set. Any advice on getting around this problem?
From R 3.0.0 onwards mean() is defunct (and passing a data.frame to mean will give the error you state)
A data frame is a list of variables of the same number of rows with unique row names, given class “data.frame”.
In your case, result has two variables (if your description is correct) . You could obtain the column means by using any of the following
lapply(results, mean, na.rm = TRUE)
sapply(results, mean, na.rm = TRUE)
colMeans(results, na.rm = TRUE)