1

maxClose 列的 是有效的,但为什么是滞后max的 Close NA

> library(quantmod)
> s <- get(getSymbols('nvmi'))
> max(Cl(s))
[1] 11.48
> max(Lag(Cl(s)))
[1] NA
> max(as.numeric(Lag(Cl(s))))
[1] NA
4

1 回答 1

1

因为LagNA默认情况下。na.rm=TRUE在您的呼叫中使用max.

> head(Cl(s))
           NVMI.Close
2007-01-03       2.60
2007-01-04       2.59
2007-01-05       2.70
2007-01-08       2.60
2007-01-09       2.47
2007-01-10       2.42
> head(Lag(Cl(s)))
           Lag.1
2007-01-03    NA
2007-01-04  2.60
2007-01-05  2.59
2007-01-08  2.70
2007-01-09  2.60
2007-01-10  2.47
> max(Lag(Cl(s)), na.rm=TRUE)
[1] 11.48
于 2013-02-21T18:11:06.420 回答