s-news
[Top] [All Lists]

tapply issue

To: s-news@wubios.wustl.edu
Subject: tapply issue
From: vincent.duval@fr.netgrs.com
Date: Mon, 18 Aug 2003 19:11:21 +0200
Hi,
I know this is something that has been discuss many time earlier in this
list but I haven't been able to find out any answer from the archives. So
maybe someone could give me a hand with my prolem.
I have a dataframe, with repeated observations ,from 2 to 5 observations,
for each subject: Number of observation vary depending of the subject.
What I am trying to do is to get the cumumative sum of the observations for
each subject.
I managed to get the result I want through the "tapply" function. But it
sorts out a list that I would like to transforme as a dataframe with one
colonne for ID and the second 
for the cumulative sum.

tapply(temp$tex,list(temp$id),cumsum) # temp$tex is 1 at every column which
gave me the following output.

$"23236":
[1] 1 2

$"23467":
[1] 1 2 3 4 5

$"23487":
[1] 1 2 3 4 5

$"23505":
[1] 1 2 3 4 5

$"23258":
[1] 1 2

$"23425":
[1] 1 2 3 4 5

$"23630":
[1] 1 2 3 4 5

$"6061":
[1] 1 2 3 4 5

$"23120":
[1] 1 2

$"23191":
[1] 1 2

This output gave the correct results, but I can not manage to get transform
such list into a dataframe, or maybe there is other ways around to get the
expected result.
Anyhelp would be very wellcome,

Thanks a lot,

Vincent




<Prev in Thread] Current Thread [Next in Thread>