Why some functions do not ignore null values in R?

走远了吗. 提交于 2019-12-13 11:14:21

问题


I have a time series of daily returns. Observations for which no data were available have value NaN.

Trying to apply functions such as StdDev from the PerformanceAnalytics package the function correctly performs calculations and returns the standard deviation for only the not Null values.

Trying to apply functions such as mean, min, max... return instead a wrong result, i.e. NaN.

There is probably something to specify in the "mean" function?


回答1:


From ?mean:

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

min and max also take an na.rm argument.

Finally, it may be worth familiarizing yourself with ?na.omit.



来源:https://stackoverflow.com/questions/15617876/why-some-functions-do-not-ignore-null-values-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!