Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20081202/10f66fc6/attachment.pl>
'str' is your friend. Look at the results:> alpha2=as.Date("2008-12-21") > alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") > alpha1Time difference of 56 days> alpha2[1] "2008-12-21"> alpha1+alpha2Time difference of 14290 days Warning message: Incompatible methods ("Ops.difftime", "+.Date") for "+"> str(alpha1)Class 'difftime' atomic [1:1] 56 ..- attr(*, "units")= chr "days"> str(alpha2)Class 'Date' num 14234>alpha1 is not of the Date class. On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang <dutangc at gmail.com> wrote:> Hi all, > > I'm dealing with dates in R (2.7.2), but some basic operations raise a > warning. > > Incompatible methods ("+.Date", "Ops.difftime") for "+" > > I saw this topic in this mailing list, but I do not understand what to > do... > > cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html > > Do I have to convert Dates to numeric? > > Thanks in advance > > Christophe > > PS : R script used > > alpha2=as.Date("2008-12-21") > alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") > alpha1 > alpha2 > alpha1+alpha2 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
If you want to do the addition, 'unclass' the variable:> alpha2+4[1] "2008-12-25"> alpha2 + unclass(alpha1)[1] "2009-02-15">On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang <dutangc at gmail.com> wrote:> Hi all, > > I'm dealing with dates in R (2.7.2), but some basic operations raise a > warning. > > Incompatible methods ("+.Date", "Ops.difftime") for "+" > > I saw this topic in this mailing list, but I do not understand what to > do... > > cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html > > Do I have to convert Dates to numeric? > > Thanks in advance > > Christophe > > PS : R script used > > alpha2=as.Date("2008-12-21") > alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") > alpha1 > alpha2 > alpha1+alpha2 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
What is odd is that it seems to run ok if we call "+.Date" directly:> "+.Date"(alpha1, alpha2)[1] "2009-02-15" On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang <dutangc at gmail.com> wrote:> Hi all, > > I'm dealing with dates in R (2.7.2), but some basic operations raise a > warning. > > Incompatible methods ("+.Date", "Ops.difftime") for "+" > > I saw this topic in this mailing list, but I do not understand what to > do... > > cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html > > Do I have to convert Dates to numeric? > > Thanks in advance > > Christophe > > PS : R script used > > alpha2=as.Date("2008-12-21") > alpha1=as.Date("2008-12-21")-as.Date("2008-10-26") > alpha1 > alpha2 > alpha1+alpha2 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >