Is there a way to test if a variable is a date?
On 7/20/2005 10:41 AM, Omar Lakkis wrote:> Is there a way to test if a variable is a date?Yes, but there are several different things people might call dates. Which do you mean? For example, > today <- Sys.Date() > today [1] "2005-07-20" > inherits(today, "Date") [1] TRUE Duncan Murdoch
If you mean of class "Date", use inherits(x, "Date"). On Wed, 20 Jul 2005, Omar Lakkis wrote:> Is there a way to test if a variable is a 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
Omar Lakkis wrote:> Is there a way to test if a variable is a date?is(variable, "Date") Uwe Ligges> ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
The type of date I am asking about is the result of an as.Date(). inherits(x, "Date") and is(variable, "Date") works for me. Thank you all. On 7/20/05, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:> Omar Lakkis wrote: > > > Is there a way to test if a variable is a date? > > > is(variable, "Date") > > Uwe Ligges > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >