Hi:
Here's another approach:
purchase_amount <- transform(purchase_amount,
diff = with(purchase_amount, ave(amount, customer, FUN =
function(x) c(0, diff(x)
purchase_amount
HTH,
Dennis
On Wed, Mar 9, 2011 at 7:27 AM, rens_1112 wrote:
> Dear all,
>
> Probably a rather stupid quest
Hi Rens,
One way would be
x$difference <- do.call(c, with(x, tapply(amount, customer, function(x) c(0,
diff(x)
x
Take a look at ?tapply and ?aggregate for more information.
HTH,
Jorge
On Wed, Mar 9, 2011 at 10:27 AM, rens_1112 <> wrote:
> Dear all,
>
> Probably a rather stupid question,
2 matches
Mail list logo