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,
Dear all,
Probably a rather stupid question, but I couldn't find the answer..
I currently have a dataframe with customers' id's and purchase amount, what
I would like to do is to show the difference between amount purchased
compared to the month before per customer.
I have made some attempts my
3 matches
Mail list logo