joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
220 stars 71 forks source link

first called on zero length input #309

Closed jangorecki closed 4 years ago

jangorecki commented 5 years ago

We have just recently spotted this inconsistency (with relation to last function) in data.table. It was now amended. It looks to be the same in xts.

A = numeric()
xts::first(A)
#[1] NA
xts::last(A)
#numeric(0)

IMO it make sense to return numeric(0) from first(numeric()). xts 0.11.2

joshuaulrich commented 4 years ago

Hi Jan, thanks for the report! I agree that both first() and last() should return numeric(0). That is consistent with head() and tail(). I will fix.