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-
Hi,
May be this helps:
dat1<- read.table(text="
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
",sep="",header=TRUE,stringsAsFactors=FALSE)
library(mondate)
M1<- mondate(dat1[,2])
M2<- mondate("01/01/2008")
dat1$month<-as.numeric(abs(floor(MonthsBetween(M1,M2
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
4 matches
Mail list logo