[R] Date Calculation

Ko-Kang Kevin Wang k.wang at auckland.ac.nz
Thu Jun 17 09:57:39 CEST 2004


I've been playing with:
> joinDate <- format(strptime(as.vector(forum[,2]), "%d-%b-%y"),
+                    "%d-%b-%Y")
> today <- format(strptime(as.vector("14-Jun-04"), "%d-%b-%Y"),
+                 "%d-%b-%Y")
> joinDate
 [1] "04-Feb-2004" "13-Feb-2004" "26-Feb-2004" "27-Feb-2004"
 [6] "27-Feb-2004" "29-Feb-2004" "01-Mar-2004" "02-Mar-2004"
[11] "08-Mar-2004" "17-Mar-2004" "20-Mar-2004" "22-Mar-2004"
[16] "23-Mar-2004" "23-Mar-2004" "24-Mar-2004" "01-Apr-2004"
[21] "01-Apr-2004" "01-Apr-2004" "02-Apr-2004" "06-Apr-2004"
[26] "11-Apr-2004" "14-Apr-2004" "03-May-2004" "04-May-2004"
[31] "01-Jun-2004" "10-Jun-2004" "14-Jun-2004" "17-Jun-2004"
> today
[1] "14-Jun-0004"
> joinDate - today
Error in joinDate - today : non-numeric argument to binary operator

But it didn't quite work.  What I'd like joinDate - today to return is
the number of days to today, since joinDate.  I'm sure it has been asked
before however a search on r-help didn't found me any relevant
information *_*.



Ko-Kang Kevin Wang, MSc(Hon)
SLC Stats Workshops Co-ordinator
The University of Auckland
New Zealand

More information about the R-help mailing list