Suppose if I consider two tables Transaction and account
where transaction$account_id contains factors and unique values in account$account_id
> transaction
      trans_id account_id amount
             1        100    500
             2        101    200
             3        102    100
             4        100    600
             5        100    700
             6        100    900
             7        101   1000
             8        101  10000
             9        102  20000
            10        101   5000
> account
  account_id Total.amnt notrans transavg
         100       2700       4      675
         101      16200       4     4050
         102      20100       2    10050
Now my question is, how to find whether amount in transaction table is greater than transavg in account table for each account_id.
And store it in a variable with factors as 1 if greater than transavg and 0 if lesser than transavg. And what packages do I need to use.
 
     
    