Wrong result from mean(x, na.rm = TRUE)
I want to compute the mean, min and max of a series of Managers returns, as follows: ManagerRet <-data.frame(diff(Managerprices)/lag(Managerprices,k=-1)) I then replace return = 0 with NaN since data are extracted from a database and not all the dates are populated. ManagerRet = replace(ManagerRet,ManagerRet==0,NaN) I have the following 3 function > min(ManagerRet,na.rm = TRUE) [1] -0.0091716 > max(ManagerRet,na.rm = TRUE) [1] 0.007565 > mean(ManagerRet,na.rm = TRUE)*252 [1] NaN Why the mean function returns a NaN value while min and max performe calculation properly? Below you can find the