[Rd] pretty.Date(): new "halfmonth" time step

Gabor Grothendieck ggrothendieck at gmail.com
Thu May 20 16:47:53 CEST 2010


Is that class publicly available?

On Thu, May 20, 2010 at 10:40 AM, Daniel Murphy <chiefmurphy at gmail.com> wrote:
> Yes. I looked at that feature of zoo. But it forced me to keep track of
> fractional months in the "Date" world. Square one. I ended up implementing a
> class under the paradigm of whole and fractional months. It allows me to do
> all my time arithmetic in ways that accountants expect. For example,
> accountants think of the close of business June 30th as being the halfway
> point of the year, but it's certainly not half the year "as the crow flies."
> -Dan
>
> On Thu, May 20, 2010 at 4:01 AM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
>>
>> Note that in the zoo package that as.Date.yearmon has a frac= argument,
>> e.g.
>>
>> > library(zoo)
>> > ym <- as.yearmon("2010-01")
>> > as.Date(ym, frac = 0.5)
>> [1] "2010-01-16"
>>
>>
>> On Wed, May 19, 2010 at 9:56 PM, Daniel Murphy <chiefmurphy at gmail.com>
>> wrote:
>> >>Much better to implement directly what this is trying to do: i.e. to
>> >>have a "halfmonth" time step. This is just the union of two "monthly"
>> >>sequences, one on the 1st of each month and another on the 15th of
>> >>each month.
>> >
>> > For some applications that might be true. But not for others. For a
>> > month
>> > with 31 days, there are 14 days before the 15th of the month and 16 days
>> > after the 15th, so, for example, March 16th (specifically noon) rather
>> > than
>> > March 15th would be the halfway point if you define "halfway" in terms
>> > of
>> > the distances to the beginning and end of the month. For a month with 30
>> > days -- like April -- the halfway point would be the instant between the
>> > 15th and the 16th of the month. Do you label that instant April 15 or
>> > April
>> > 16?  (I prefer "15".) Don't get me started on February.
>> >
>> > - Dan Murphy
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-devel at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-devel
>> >
>
>



More information about the R-devel mailing list