Skip to content

Application of "merge" and "within"

3 messages · Peter Dalgaard, Santosh

#
Notice that within-group processing is intended. I'd try
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 May 2016, at 22:53 , Duncan Murdoch <murdoch.duncan at gmail.com> wrote:

            

  
    
3 days later
#
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, as.data.frame(as.matrix(apply($DATA,2,function(x)
{require(gtools);x1 <- ifelse(invalid(x),0,x);return(x1)}))))

For some reason, the above code is not working.. any ideas on converting
NAs/blanks to 0 using apply in within? or any other similar method?

Thanks so much.. I appreciate your help!!

Regards,
Santosh
On Wed, Jun 1, 2016 at 1:45 AM, peter dalgaard <pdalgd at gmail.com> wrote:

            

  
  
5 days later
#
Hi Peter and others..
In the code from Peter..(reproduced below for convenience..)
....
....

is there a reason behind that 'ave' used in the above code?
is there way to perform a multi-column sort in within?

Thanks so much..
Santosh
On Wed, Jun 1, 2016 at 1:45 AM, peter dalgaard <pdalgd at gmail.com> wrote: