FYI, I've tried posting the below message twice to the bug tracking system, once by email (below), and the second time 5 days later directly to the bugs.r-project.org website. As far as I can tell, the bug tracking system hasn't picked this up. Also it looks like the latest "incoming" bug is dated 25 May 2008, so perhaps others are having difficulty as well. (cc: r-bugs) Cheers, Robert -----Original Message----- From: McGehee, Robert Sent: Monday, July 14, 2008 9:51 AM To: R-bugs at biostat.ku.dk Subject: sapply(Date, is.numeric) R-developers, The results below are inconsistent. From the documentation for is.numeric, I expect FALSE in both cases.> x <- data.frame(dt=Sys.Date()) > is.numeric(x$dt)[1] FALSE> sapply(x, is.numeric)dt TRUE ## Yet, sapply seems aware of the Date class> sapply(x, class)dt "Date" platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.0 year 2008 month 04 day 22 svn rev 45424 language R version.string R version 2.7.0 (2008-04-22) Thanks, Robert McGehee, CFA Geode Capital Management, LLC One Post Office Square, 28th Floor | Boston, MA | 02109 Tel: 617/392-8396 Fax:617/476-6389 mailto:robert.mcgehee at geodecapital.com This e-mail, and any attachments hereto, are intended fo...{{dropped:12}}
Martin Maechler
2008-Jul-30 08:04 UTC
[Rd] R-bugs e-mail problems {was "sapply(Date, is.numeric)"}
>>>>> "RobMcG" == McGehee, Robert <Robert.McGehee at geodecapital.com> >>>>> on Tue, 29 Jul 2008 15:40:37 -0400 writes:RobMcG> FYI, RobMcG> I've tried posting the below message twice to the bug tracking system, RobMcG> once by email (below), and the second time 5 days later directly to the RobMcG> bugs.r-project.org website. As far as I can tell, the bug tracking RobMcG> system hasn't picked this up. Also it looks like the latest "incoming" RobMcG> bug is dated 25 May 2008, so perhaps others are having difficulty as RobMcG> well. (cc: r-bugs) Well, if you look into the *trashcan*, you find the latest ones to be from 'July 4' , (and it may well have been who cleaned up the incoming mess, moving 95% of the messages to the trashcan); so the mail-interface seemed to have stopped at the US national holiday. Given how ineffective our spam filters have become there, it may not be a big harm :-) There have plans for a long time to change to a new bug report system (probably with*out* e-mail interface - alas!), but there have been diverse reasons why this has never happened. One of the reasons: We'd want to migrate the current repository (all the "bug - fix threads", apart from the trashcan) to the new system, and I think haven't found anyone to do that for us. We had even considered the R foundation would offer a monetary amount to someone (smart programmer) to program the one-time migration, but that somehow failed, too? I'm getting really off-topic, but this my be worthwhile theme to open just before meeting many at the useR!2008 in Dortmund. Martin Maechler, ETH Zurich and R-Core
>>>>> "RobMcG" == McGehee, Robert <Robert.McGehee at geodecapital.com> >>>>> on Tue, 29 Jul 2008 15:40:37 -0400 writes:RobMcG> FYI, RobMcG> I've tried posting the below message twice to the bug tracking system, [....... r-bugs problems discussed in a separate thread ....] RobMcG> R-developers, RobMcG> The results below are inconsistent. From the documentation for RobMcG> is.numeric, I expect FALSE in both cases. >> x <- data.frame(dt=Sys.Date()) >> is.numeric(x$dt) RobMcG> [1] FALSE >> sapply(x, is.numeric) RobMcG> dt RobMcG> TRUE RobMcG> ## Yet, sapply seems aware of the Date class >> sapply(x, class) RobMcG> dt RobMcG> "Date" Yes, thanks a lot, Robert, for the report. That *is* a bug somewhere in the .Internal(lapply(...)) C code, when S3 dispatch of primitive functions should happen. Here's an R scriptlet exposing a 2nd example ### lapply(list, FUN) ### ------------------ seems to sometimes fail for ### .Primitive S3-generic functions (ds <- seq(from=Sys.Date(), by=1, length=4)) ##[1] "2008-07-30" "2008-07-31" "2008-08-01" "2008-08-02" ll <- list(d=ds) lapply(list(d=ds), round) ## -> Error in lapply(list(d = ds), round) : dispatch error ## or -- related to bug report by Robert McGehee on R-devel, on 2008-07-29: sapply(list(d=ds), is.numeric) ## TRUE ## in spite of is.numeric(`[[`(ll,1)) ## FALSE , because of is.numeric.date ## or round(`[[`(ll,1)) ## [1] "2008-07-30" "2008-07-31" "2008-08-01" "2008-08-02" ##----------------------------- But I'm currently too much tied up with other duties, to find and test bug-fix. Martin Maechler, ETH Zurich and R-Core Team
Try this workaround> sapply(x, function(x) is.numeric(x))dt FALSE is.numeric is primitive, and primitive functions don't always play well with [sl]apply. On Tue, 29 Jul 2008, McGehee, Robert wrote:> FYI, > I've tried posting the below message twice to the bug tracking system, > once by email (below), and the second time 5 days later directly to the > bugs.r-project.org website. As far as I can tell, the bug tracking > system hasn't picked this up. Also it looks like the latest "incoming" > bug is dated 25 May 2008, so perhaps others are having difficulty as > well. (cc: r-bugs) > > Cheers, Robert > > > -----Original Message----- > From: McGehee, Robert > Sent: Monday, July 14, 2008 9:51 AM > To: R-bugs at biostat.ku.dk > Subject: sapply(Date, is.numeric) > > R-developers, > The results below are inconsistent. From the documentation for > is.numeric, I expect FALSE in both cases. > >> x <- data.frame(dt=Sys.Date()) >> is.numeric(x$dt) > [1] FALSE >> sapply(x, is.numeric) > dt > TRUE > > ## Yet, sapply seems aware of the Date class >> sapply(x, class) > dt > "Date" > > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 7.0 > year 2008 > month 04 > day 22 > svn rev 45424 > language R > version.string R version 2.7.0 (2008-04-22) > > Thanks, > > Robert McGehee, CFA > Geode Capital Management, LLC > One Post Office Square, 28th Floor | Boston, MA | 02109 > Tel: 617/392-8396 Fax:617/476-6389 > mailto:robert.mcgehee at geodecapital.com > > > > This e-mail, and any attachments hereto, are intended fo...{{dropped:12}} > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595