Re: [R] Application of "merge" and "within"

2016-06-10 Thread Santosh
Hi Peter and others.. In the code from Peter..(reproduced below for convenience..) > first <- function(x)x[1] > s <- within(q, {bl <- ave(b, paste(G,a), FUN=first); db <- b - bl}) is there a reason behind that 'ave' used in the above code? is there way to perform a multi-column sort in

Re: [R] Application of "merge" and "within"

2016-06-04 Thread Santosh
Thanks so much.. I will try that.. and keep you posted.. on a different note.. using the above examples.. after adding a new column is blank.. summarizing a null column causes errors.. (like min(NULL) or min(NA) etc.. to avoid that I was trying the following code.. within(q,

Re: [R] Application of "merge" and "within"

2016-06-01 Thread peter dalgaard
Notice that within-group processing is intended. I'd try > first <- function(x)x[1] > s <- within(q, {bl <- ave(b, paste(G,a), FUN=first); db <- b - bl}) Or perhaps q <- within(q, Ga <- paste(G,a)) tbl <- with(q, tapply(b, Ga, first)) s <- within(q, {bl <- tbl[Ga]; db <- b - bl}) -pd On 28

Re: [R] Application of "merge" and "within"

2016-05-31 Thread Jeff Newmiller
Then perhaps your example should illustrate one of these "many situations" that trouble you but you are not being clear about. -- Sent from my phone. Please excuse my brevity. On May 31, 2016 11:39:04 AM PDT, Santosh wrote: >I agree that performing merge outside the

Re: [R] Application of "merge" and "within"

2016-05-31 Thread Santosh
I agree that performing merge outside the scope of "within" function, is pretty straight forward.. At times there are situations when many, if not all, of the operations are needed to be done within the scope the "within" environment.. Thanks so much.. Regards, Santosh On Tue, May 31, 2016 at

Re: [R] Application of "merge" and "within"

2016-05-31 Thread Jeff Newmiller
What is complicated about merge( q, r )? Keep in mind that there is nothing simple about the rules for non-standard evaluation of variables that within() uses, and it only gets more complicated if you try to apply those rules to two data frames at once. While I am not quite sure I understand

Re: [R] Application of "merge" and "within"

2016-05-31 Thread Santosh
Thanks for response.. I want to merge two data frames using "within" function..the columns to used for merge could vary.. then the other commands become simpler.. Thanks so much for your help! Santosh On Sat, May 28, 2016 at 1:53 PM, Duncan Murdoch wrote: > On

Re: [R] Application of "merge" and "within"

2016-05-28 Thread Duncan Murdoch
On 27/05/2016 7:00 PM, Santosh wrote: Dear Rxperts! Is there a way to compute relative values.. using within().. function? Any assistance/suggestions are highly welcome!! Thanks again, Santosh... ___ A sample dataset and the

Re: [R] Application of "merge" and "within"

2016-05-28 Thread Jeff Newmiller
Why do you want to do this? -- Sent from my phone. Please excuse my brevity. On May 27, 2016 4:00:14 PM PDT, Santosh wrote: >Dear Rxperts! > >Is there a way to compute relative values.. using within().. function? > >Any assistance/suggestions are highly welcome!! >Thanks

[R] Application of "merge" and "within"

2016-05-27 Thread Santosh
Dear Rxperts! Is there a way to compute relative values.. using within().. function? Any assistance/suggestions are highly welcome!! Thanks again, Santosh... ___ A sample dataset and the computation "outside" within() function is