Bug in na.locf() example
Closed this issue · 1 comments
joshuaulrich commented
An upcoming change in xts causes the last example in na.Rd
to fail. The problem is that "2003:2005"
is not a valid xts-ISO8601 range; it should be "2003::2005"
or "2003/2005"
.
Prior to the upcoming xts_0.11-0, an invalid xts-ISO8601 range would return all rows. It now returns no data with a warning, which causes the example to error.
data(air)
rural = STFDF(stations, dates, data.frame(PM10 = as.vector(air)))
# fill NA's with last non-NA
r = na.locf(rural)
# sample (NOT aggregate) to monthly:
m = seq(start(rural), end(rural), "1 month")
stplot(na.approx(rural[1:20,"2003:2005"], xout = m), mode = 'ts')
# Warning in .parseISO8601(ii, .index(x)[1], .index(x)[nr], tz = tz) :
# cannot determine first and last time from 2003:2005/2003:2005
# Error in matrix(v, nr, nc)[s, t] : subscript out of bounds
# Calls: stplot ... .class1 -> [ -> [ -> data.frame -> lapply -> FUN -> as.vector
# Execution halted
I may change the behavior so it returns all rows with a warning, and a note that future versions will return no data. That will delay when the change will begin to break existing code.
edzer commented
Thanks @joshuaulrich ! I will submit this to CRAN.