P.Dalgaard at biostat.ku.dk
2007-Dec-11 16:05 UTC
[Rd] range( <dates>, na.rm = TRUE ) (PR#10508)
(Drats! Jitterbug is playing tricks with the PR# again. Attempting to refile so that we can kill PR#10509) Peter Dalgaard wrote:> Kurt.Hornik at wu-wien.ac.at wrote: > =20 >> ------- Start of forwarded message ------- >> Date: Tue, 13 Nov 2007 21:44:57 +0100 >> To: Steve Mongin <sjm at ccbr.umn.edu> >> Cc: cran at r-project.org >> Subject: Re: range( <dates>, na.rm =3D TRUE ) >> In-Reply-To: <200711062044.OAA14064 at minnow.ccbr.umn.edu> >> Reply-To: Kurt.Hornik at wu-wien.ac.at >> From: Kurt Hornik <Kurt.Hornik at wu-wien.ac.at> >> X-AntiVirus: checked by AntiVir MailGate (version: 2.1.3-2; AVE: 7.6.0=2E34; VDF: 7.0.0.210; host: fsme.wu-wien.ac.at) >> X-Virus-Scanned: ClamAV 0.90.3/4768/Tue Nov 13 18:25:08 2007 on pocken=2Ewu-wien.ac.at >> X-Virus-Status: Clean >> >> =20 >> =20 >>>>>>> Steve Mongin writes: >>>>>>> =20 >>>>>>> =20 >> =20 >> =20 >>> Dear CRAN: >>> I am running 'R' on Linux as follows: >>> =20 >>> =20 >> =20 >> =20 >>>> version >>>> =20 >>>> =20 >>> _ =20 >>> platform i686-redhat-linux-gnu =20 >>> arch i686 =20 >>> os linux-gnu =20 >>> system i686, linux-gnu =20 >>> status =20 >>> major 2 =20 >>> minor 6.0 =20 >>> year 2007 =20 >>> month 10 =20 >>> day 03 =20 >>> svn rev 43063 =20 >>> language R =20 >>> version.string R version 2.6.0 (2007-10-03) >>> =20 >>> =20 >> =20 >> =20 >>> I have a question about the behavior of "range()" with missing dates. >>> =20 >>> =20 >> =20 >> =20 >>> With the previous version (2.4?) , the command: >>> =20 >>> =20 >> =20 >> =20 >>>> range( as.Date( c( "2007-11-06", NA ) ), na.rm =3D TRUE ) >>>> =20 >>>> =20 >> =20 >> =20 >>> yielded: >>> =20 >>> =20 >> =20 >> =20 >>>> [1] "2007-11-06" "2007-11-06" >>>> =20 >>>> =20 >> =20 >> =20 >>> Now I get: >>> =20 >>> =20 >> =20 >> =20 >>>> [1] NA NA >>>> =20 >>>> =20 >> =20 >> =20 >>> Is this a bug? >>> =20 >>> =20 >> =20 >> =20 >>> Yes, I see in the "What's New" page: >>> =20 >>> =20 >> =20 >> =20 >>> "The Math2 and Summary groups (round, signif, all, any, max, min, >>> summ, prod, range) are now primitive." >>> =20 >>> =20 >> =20 >> =20 >>> Is the "primitive" characteristic supposed to behave as above with >>> missing dates? >>> =20 >>> =20 >> =20 >> =20 >>> Thanks for any help that you can provide. >>> =20 >>> =20 >> This is really a question for r-devel or r-bugs, I think, but not for >> the CRAN maintainers. >> >> I would think it is a bug. Perhaps simply file a bug report? >> >> =20 >> =20 > Again? ;-) > > The bug is here: > > =20 >> range.default >> =20 > function (..., na.rm =3D FALSE, finite =3D FALSE) > { > x <- c(..., recursive =3D TRUE) > if (is.numeric(x)) { > if (finite) > x <- x[is.finite(x)] > else if (na.rm) > x <- x[!is.na(x)] > } > c(min(x), max(x)) > } > <environment: namespace:base> > > Objects of class Date are not considered numeric, so we end up taking > min and max without removing NA. > > One solution could be > > if (is.numeric(x) || inherits(x, "Date") ){....} > > > =20--=20 O__ ---- Peter Dalgaard =C3=98ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
ripley at stats.ox.ac.uk
2007-Dec-11 16:20 UTC
[Rd] range( <dates>, na.rm = TRUE ) (PR#10508)
I don't think that is the right fix. All methods for min/max should now support na.rm=TRUE (but not finite=TRUE), so range.default should just call min and max with that argument. I'd need to verify those 'should's first .... Brian On Tue, 11 Dec 2007, Peter Dalgaard wrote:> (Drats! Jitterbug is playing tricks with the PR# again. Attempting to > refile so that we can kill PR#10509) > > Peter Dalgaard wrote: >> Kurt.Hornik at wu-wien.ac.at wrote: >> >>> ------- Start of forwarded message ------- >>> Date: Tue, 13 Nov 2007 21:44:57 +0100 >>> To: Steve Mongin <sjm at ccbr.umn.edu> >>> Cc: cran at r-project.org >>> Subject: Re: range( <dates>, na.rm = TRUE ) >>> In-Reply-To: <200711062044.OAA14064 at minnow.ccbr.umn.edu> >>> Reply-To: Kurt.Hornik at wu-wien.ac.at >>> From: Kurt Hornik <Kurt.Hornik at wu-wien.ac.at> >>> X-AntiVirus: checked by AntiVir MailGate (version: 2.1.3-2; AVE: 7.6.0.34; VDF: 7.0.0.210; host: fsme.wu-wien.ac.at) >>> X-Virus-Scanned: ClamAV 0.90.3/4768/Tue Nov 13 18:25:08 2007 on pocken.wu-wien.ac.at >>> X-Virus-Status: Clean >>> >>> >>> >>>>>>>> Steve Mongin writes: >>>>>>>> >>>>>>>> >>> >>> >>>> Dear CRAN: >>>> I am running 'R' on Linux as follows: >>>> >>>> >>> >>> >>>>> version >>>>> >>>>> >>>> _ >>>> platform i686-redhat-linux-gnu >>>> arch i686 >>>> os linux-gnu >>>> system i686, linux-gnu >>>> status >>>> major 2 >>>> minor 6.0 >>>> year 2007 >>>> month 10 >>>> day 03 >>>> svn rev 43063 >>>> language R >>>> version.string R version 2.6.0 (2007-10-03) >>>> >>>> >>> >>> >>>> I have a question about the behavior of "range()" with missing dates. >>>> >>>> >>> >>> >>>> With the previous version (2.4?) , the command: >>>> >>>> >>> >>> >>>>> range( as.Date( c( "2007-11-06", NA ) ), na.rm = TRUE ) >>>>> >>>>> >>> >>> >>>> yielded: >>>> >>>> >>> >>> >>>>> [1] "2007-11-06" "2007-11-06" >>>>> >>>>> >>> >>> >>>> Now I get: >>>> >>>> >>> >>> >>>>> [1] NA NA >>>>> >>>>> >>> >>> >>>> Is this a bug? >>>> >>>> >>> >>> >>>> Yes, I see in the "What's New" page: >>>> >>>> >>> >>> >>>> "The Math2 and Summary groups (round, signif, all, any, max, min, >>>> summ, prod, range) are now primitive." >>>> >>>> >>> >>> >>>> Is the "primitive" characteristic supposed to behave as above with >>>> missing dates? >>>> >>>> >>> >>> >>>> Thanks for any help that you can provide. >>>> >>>> >>> This is really a question for r-devel or r-bugs, I think, but not for >>> the CRAN maintainers. >>> >>> I would think it is a bug. Perhaps simply file a bug report? >>> >>> >>> >> Again? ;-) >> >> The bug is here: >> >> >>> range.default >>> >> function (..., na.rm = FALSE, finite = FALSE) >> { >> x <- c(..., recursive = TRUE) >> if (is.numeric(x)) { >> if (finite) >> x <- x[is.finite(x)] >> else if (na.rm) >> x <- x[!is.na(x)] >> } >> c(min(x), max(x)) >> } >> <environment: namespace:base> >> >> Objects of class Date are not considered numeric, so we end up taking >> min and max without removing NA. >> >> One solution could be >> >> if (is.numeric(x) || inherits(x, "Date") ){....} >> >> >> > > >-- 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
P.Dalgaard at biostat.ku.dk
2007-Dec-11 16:40 UTC
[Rd] range( <dates>, na.rm = TRUE ) (PR#10508)
Prof Brian Ripley wrote:> I don't think that is the right fix. All methods for min/max should > now support na.rm=3DTRUE (but not finite=3DTRUE), so range.default should > just call min and max with that argument. > > I'd need to verify those 'should's first .... >OK, that why I didn't touch the sources.... -p> Brian > > On Tue, 11 Dec 2007, Peter Dalgaard wrote: > >> (Drats! Jitterbug is playing tricks with the PR# again. Attempting to >> refile so that we can kill PR#10509) >> >> Peter Dalgaard wrote: >>> Kurt.Hornik at wu-wien.ac.at wrote: >>> >>>> ------- Start of forwarded message ------- >>>> Date: Tue, 13 Nov 2007 21:44:57 +0100 >>>> To: Steve Mongin <sjm at ccbr.umn.edu> >>>> Cc: cran at r-project.org >>>> Subject: Re: range( <dates>, na.rm =3D TRUE ) >>>> In-Reply-To: <200711062044.OAA14064 at minnow.ccbr.umn.edu> >>>> Reply-To: Kurt.Hornik at wu-wien.ac.at >>>> From: Kurt Hornik <Kurt.Hornik at wu-wien.ac.at> >>>> X-AntiVirus: checked by AntiVir MailGate (version: 2.1.3-2; AVE: >>>> 7.6.0.34; VDF: 7.0.0.210; host: fsme.wu-wien.ac.at) >>>> X-Virus-Scanned: ClamAV 0.90.3/4768/Tue Nov 13 18:25:08 2007 on >>>> pocken.wu-wien.ac.at >>>> X-Virus-Status: Clean >>>> >>>> >>>> >>>>>>>>> Steve Mongin writes: >>>>>>>>> >>>>>>>>> >>>> >>>> >>>>> Dear CRAN: >>>>> I am running 'R' on Linux as follows: >>>>> >>>>> >>>> >>>> >>>>>> version >>>>>> >>>>>> >>>>> _ >>>>> platform i686-redhat-linux-gnu >>>>> arch i686 >>>>> os linux-gnu >>>>> system i686, linux-gnu >>>>> status >>>>> major 2 >>>>> minor 6.0 >>>>> year 2007 >>>>> month 10 >>>>> day 03 >>>>> svn rev 43063 >>>>> language R >>>>> version.string R version 2.6.0 (2007-10-03) >>>>> >>>>> >>>> >>>> >>>>> I have a question about the behavior of "range()" with missing dates. >>>>> >>>>> >>>> >>>> >>>>> With the previous version (2.4?) , the command: >>>>> >>>>> >>>> >>>> >>>>>> range( as.Date( c( "2007-11-06", NA ) ), na.rm =3D TRUE ) >>>>>> >>>>>> >>>> >>>> >>>>> yielded: >>>>> >>>>> >>>> >>>> >>>>>> [1] "2007-11-06" "2007-11-06" >>>>>> >>>>>> >>>> >>>> >>>>> Now I get: >>>>> >>>>> >>>> >>>> >>>>>> [1] NA NA >>>>>> >>>>>> >>>> >>>> >>>>> Is this a bug? >>>>> >>>>> >>>> >>>> >>>>> Yes, I see in the "What's New" page: >>>>> >>>>> >>>> >>>> >>>>> "The Math2 and Summary groups (round, signif, all, any, max, min, >>>>> summ, prod, range) are now primitive." >>>>> >>>>> >>>> >>>> >>>>> Is the "primitive" characteristic supposed to behave as above with >>>>> missing dates? >>>>> >>>>> >>>> >>>> >>>>> Thanks for any help that you can provide. >>>>> >>>>> >>>> This is really a question for r-devel or r-bugs, I think, but not for >>>> the CRAN maintainers. >>>> >>>> I would think it is a bug. Perhaps simply file a bug report? >>>> >>>> >>>> >>> Again? ;-) >>> >>> The bug is here: >>> >>> >>>> range.default >>>> >>> function (..., na.rm =3D FALSE, finite =3D FALSE) >>> { >>> x <- c(..., recursive =3D TRUE) >>> if (is.numeric(x)) { >>> if (finite) >>> x <- x[is.finite(x)] >>> else if (na.rm) >>> x <- x[!is.na(x)] >>> } >>> c(min(x), max(x)) >>> } >>> <environment: namespace:base> >>> >>> Objects of class Date are not considered numeric, so we end up taking >>> min and max without removing NA. >>> >>> One solution could be >>> >>> if (is.numeric(x) || inherits(x, "Date") ){....} >>> >>> >>> >> >> >> >--=20 O__ ---- Peter Dalgaard =C3=98ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Reasonably Related Threads
- [Kurt.Hornik@wu-wien.ac.at: Re: range( <dates>, na.rm = TRUE )] (PR#10508)
- [Kurt.Hornik@wu-wien.ac.at: Re: range( <dates>, na.rm = (PR#10509)
- How to rbind list of vectors with unequal vector lengths?
- creating a reverse geometric sequence
- How to check the available of a package on R repo