nesvarbu
nesvarbu

Reputation: 1016

A difference between startof and firstof values of indexAt parameter in to.period

According to the documentation:

To adjust the final indexing style, it is possible to set indexAt to one of the following: ‘yearmon’, ‘yearqtr’, ‘firstof’, ‘lastof’, ‘startof’, or ‘endof’. The final index will then be yearmon, yearqtr, the first time of the period, the last time of the period, the starting time in the data for that period, or the ending time in the data for that period, respectively.

Now I try to do to.hourly for my minute data. I see that all values by default is set to the last minute in data. I want to set to the first minute. It seems indexAt is parameter exactly for that. I have one hour that starts at 09:30. As I understand from description 'firstof' should set it to 09:00 (first minute of hourly period) and 'startof' should set it to 09:30 (first available minute in hour data). 'startof' seems to work for me but 'firstof' does not work and still returns 09:59! Am I missing something?

Upvotes: 1

Views: 270

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176648

If you look at the Usage section of ?to.period, you will see that only to.monthly and to.quarterly have indexAt arguments. That is why to.hourly ignores the indexAt argument.

Issue #158 briefly discusses the possibility of adding indexAt support for periods other than monthly and quarterly.

Upvotes: 2

Related Questions