Skip to content
Back to formatted view

Raw Message

Message-ID: <Zen-1Ta7Q6-00038x-Co@smarthost03.mail.zen.net.uk>
Date: 2012-11-18T16:08:25Z
From: Michael Dewey
Subject: manipulating longitudinal data in r
In-Reply-To: <1353142592.16507.YahooMailClassic@web133106.mail.ir2.yahoo .com>

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