FW: [R] is.weekend() odd behaviour

About this list Date view Thread view Subject view Author view Attachment view

From: Matthew Dowle (mdowle@concordiafunds.com)
Date: Thu 27 May 2004 - 00:36:42 EST


Message-id: <78166BFC5165D811AA0400065BF0324B1B918A@wisconsin.concordia>


Kurt,

Uwe suggested I write to you as maintainer of chron ... at the start of
is.weekend, in the check on the argument type, maybe just change chron() to
as.chron()? This would ensure as.chron.POSIXt gets called on POSIXt
arguments, and (I think) fixes the problem. I tested and it seems ok. No
warning/error required.

> is.weekend
function(x)
{
    if(!inherits(x, "dates"))
        if(is.character(x) || is.numeric(x))
            x <- as.chron(x) # was x <- chron(x)
        else stop("x must inherit from dates")
    ....
}

-----Original Message-----
From: Uwe Ligges [mailto:ligges@statistik.uni-dortmund.de]
Sent: 26 May 2004 13:20
To: Matthew Dowle
Cc: 'r-help@stat.math.ethz.ch'
Subject: Re: [R] is.weekend() odd behaviour

Matthew Dowle wrote:

> Thanks. When is.weekend() is given an object it doesn't know about,
> could a warning or error be added? At the moment, I think you're
> agreeing, that it silently returns a random TRUE/FALSE.

It's not random, it depends on the value of Sys.time(), which also
includes seconds .....
I agree that a warning or error might be sensible. So I think you are
about to write a note to the maintainer of package "chron" including
patches for is.weekend() and friends?

Uwe Ligges

> -----Original Message-----
> From: Uwe Ligges [mailto:ligges@statistik.uni-dortmund.de]
> Sent: 26 May 2004 11:55
> To: Matthew Dowle
> Cc: 'r-help@stat.math.ethz.ch'
> Subject: Re: [R] is.weekend() odd behaviour
>
>
> Matthew Dowle wrote:
>
>
>>It seems is.weekend() is unsure ?
>
>
> It is completely sure, if an object is given is.weekend() knows about
> as in:
>
> table(is.weekend(sapply(1:100,
> function(i){Sys.sleep(0.05);as.chron(Sys.time())})))
>
> (note the as.chron() call!)
>
> Uwe Ligges
>
>
>
>
>># Start R 1.9.0 with --vanilla on windows xp
>># load package chron
>>
>>
>>
>>>table(is.weekend(sapply(1:100,
>>>function(i){Sys.sleep(0.05);Sys.time()})))
>>
>>FALSE TRUE
>> 68 32
>>
>>
>>>date()
>>
>>[1] "Wed May 26 11:18:56 2004"
>>
>>
>>
>>>version _
>>
>>platform i386-pc-mingw32
>>arch i386
>>os mingw32
>>system i386, mingw32
>>status
>>major 1
>>minor 9.0
>>year 2004
>>month 04
>>day 12
>>language R
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>>______________________________________________
>>R-help@stat.math.ethz.ch mailing list
>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!
>>http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:12 EST