为什么有些函数不会忽略R中的空值? [英] Why some functions do not ignore null values in R?
问题描述
NaN
。 尝试应用
函数正确执行计算,并仅返回非空值的标准偏差。 PerformanceAnalytics
包中的StdDev
尝试应用诸如平均值
, min
, max
...返回错误的结果,即 NaN
。
可能是在 mean
函数中指定的东西?
?mean
:
$ b
na.rm
一个逻辑值,指示在计算进行之前是否应该剥离NA值。
min
和 max
也取一个n na.rm
参数。
最后,可能值得熟悉 > 。
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?
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
.
这篇关于为什么有些函数不会忽略R中的空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!