Re: [R] Function with multiple indices

2012-04-17 Thread Rui Barradas
Hello, In your first call, perf(GROUP11), you're passing a data.frame, in the 'tapply' and 'aggregate' you are passing a vector, x1$SALES, and the operator '$' is not valid. > tapply(x1$SALES, list(x1$YEAR, x1$GROUP), perf) Error in x$SALES : $ operator is invalid for atomic vectors There's anot

[R] Function with multiple indices

2012-04-17 Thread cfchang3
Hi, I wrote a function which works for one group but not for multiple groups in several years. Could anyone help me out? The dateset has 3 variables, year, group, and sales. I want to calculate the annual group median adjusted sales performance for observation i in group j and year yr, I do th