Hello,
It's better if you keep it on the list, the odds of getting more and
better answers is greater.
As for your question, I've made up a dat2 with an extra column. Try the
following, it's independent of the number of columns.
dat2 <- data.frame(ID = dat1$ID,
month = mondf("01/0
Hello,
The functions in stackoverflow need a date 'format' argument.
# Functions from
#
http://stackoverflow.com/questions/1995933/number-of-months-between-two-dates
# with a 'format' argument added
#
# turn a date into a 'monthnumber' relative to an origin
monnb <- function(d, format = "%Y-
;-as.numeric(abs(floor(MonthsBetween(M1,M2
dat1
# ID date month
#1 1 4/12/2008 4
#2 1 4/13/2008 4
#3 1 5/11/2008 5
#4 2 3/21/2009 15
#5 2 4/22/2009 16
#6 2 8/05/2009 20
A.K.
- Original Message -
From: Gallon Li
To: r-help
Cc:
Sent: Thursday, July 11
Hi.
See
http://stackoverflow.com/questions/1995933/number-of-months-between-two-dates
Andrija
On Thu, Jul 11, 2013 at 11:56 AM, Gallon Li wrote:
> My data are from 2008 to 2010, with repeated measures for same subjects. I
> wish to compute number of months since january 2008.
>
> The data are
My data are from 2008 to 2010, with repeated measures for same subjects. I
wish to compute number of months since january 2008.
The data are like the following:
ID date
1 4/12/2008
1 4/13/2008
1 5/11/2008
2 3/21/2009
2 4/22/2009
2 8/05/2009
...
the date column are in the format "%m/%d/%y". i wis
5 matches
Mail list logo