Re: [R] calculate time from dates

2013-07-12 Thread Rui Barradas
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

Re: [R] calculate time from dates

2013-07-11 Thread Rui Barradas
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-

Re: [R] calculate time from dates

2013-07-11 Thread arun
;-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

Re: [R] calculate time from dates

2013-07-11 Thread andrija djurovic
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

[R] calculate time from dates

2013-07-11 Thread Gallon Li
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