I have a data frame (process.yield):
process Yield 35 0.38 37 0.29 89 0.75 90 0.82
I want R to calculate the mean of values in column 2 ("Yield"). This seems trivial, but somehow after applying functions like apply, aggregate, mean, by, I have not been able to get the right results. I'm guessing there is a problem with my data frame.
Example: Aggregate function:
process.yield.mean <- aggregate(process.yield, by=list(process.yield$Yield), FUN=mean)
Error from aggregate function:
1: In mean.default(X[[1L]], ...) : argument is not numeric or logical: returning NA etc etc
Can anyone help please?
The error message is telling you that the thing you are passing to
mean()isn't a numeric or a logical vector. Use
class()to work out what your column is (most likely a character vector?) and convert it. If you are reading this data in from .csv you may find some of the entries in that column are not, in fact, numbers?