max
Close 列的 是有效的,但为什么是滞后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
因为Lag
垫NA
默认情况下。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