Well, it should be difference by ID and TIME for q1:
something like:
for ID 1187
in TIME 1                       q1=3
and TIME 2 (for same ID) q1=3
so diff would be 3-3=0

TIME   ID  q1
   1  1187  3
   1  1187  3

And I don't know how to make R to find pairs and calculate diff?

2011/2/21 Dennis Murphy <djmuser@gmail.com>

> Hi:
>
> Assuming dd is the name of your data frame,
>
> > dd$diff <- with(dd, q2 - q1)
> > dd
>   TIME   ID q1 q2 diff
> 1    1 1187  3  2   -1
> 2    1 1706  3  3    0
>
> 3    1 1741  2  4    2
> 4    2 1187  3  2   -1
> 5    2 1706  3  3    0
> 6    2 1741  2  4    2
>
> is one way to do it.
>
> HTH,
> Dennis
>
> On Mon, Feb 21, 2011 at 11:05 AM, Vlatka Matkovic Puljic <
> v.matkovic.puljic@gmail.com> wrote:
>
>> Dear all,
>>
>> I want to perform paired Wilcoxon signed ranks test on my data.
>> I have pairs defined by ID and TIME variables.
>>
>> How can I calculate difference in variables q1, q2 in each pair?
>>
>> TIME ID q1 q2
>> 1 1187 3 2
>> 1 1706 3 3
>> 1 1741 2 4
>> 2 1187 3 2
>> 2 1706 3 3
>> 2 1741 2 4
>>
>> Please, any clue!
>> :)
>>
>>
>> --
>> **************************
>> Vlatka Matkovic Puljic
>> +32/ 485/ 453340
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>


-- 
**************************
Vlatka Matkovic Puljic
+32/ 485/ 453340

	[[alternative HTML version deleted]]

