Re: [R] how to calculate the mean in a period of time?

2013-05-22 Thread arun
HI GG, I thought you were referring about the solution that I sent today.  Sorry, I didn't check it. TRy this: dat1- read.table(text= patient_id  number  responsed_at  delais  scores1   scores2   scores3  1  1    2010-05-26 NA   2.6   

Re: [R] how to calculate the mean in a period of time?

2013-05-17 Thread arun
Hi, Try this:  dat1$idx-with(dat1,ifelse(is.na(delais)|delais45 delais20, 1,ifelse(delais60 delais=45,2,ifelse(delais=90 delais=60,3,NA dat1$idx1-c(dat1$idx[-head(dat1$idx,1)],1) library(zoo) res1-do.call(rbind,lapply(split(dat1,dat1$patient_id),function(x)

Re: [R] how to calculate the mean in a period of time?

2013-05-16 Thread arun
Hi, The output you showed is not clear especially the for the scores3,   2                         2           2011-09-22    3     65            2.6       0.8            0.8 2                        3             2011-10-26   4      34            2.7     0.8            0.8 3                    

Re: [R] how to calculate the mean in a period of time?

2013-05-07 Thread arun
Hi, Your question is still not clear. May be this helps: dat2- read.table(text= patient_id  t scores 1  0    1.6 1  1    2.6 1  2 2.2 1  3 1.8 2