manipulating longitudinal data in r
At 08:56 17/11/2012, Kemi Racheal wrote:
Dear list member, I have the following data example ke <- data.frame(patid=c(1,1,1,2,3,3),a=c(1,2,2,1,1,2)) I want to add another variable b, such that the max of 'a' by id is returned i.e data ke becomes ke <- data.frame(patid=c(1,1,1,2,3,3),a=c(1,2,2,1,1,2),b=c(2,2,2,1,2,2)) Any help will be appreciated.
Dear Kemi It is often easier to do some sorts of manipulations on the wide format of the data. I appreciate that you can always do it both ways.
Oluwakemi
[[alternative HTML version deleted]]
Michael Dewey info at aghmed.fsnet.co.uk http://www.aghmed.fsnet.co.uk/home.html