[R] how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work

2007-03-07 Thread ALAN SMITH
Hello R users, Problem...I do not understand how to use "aggregate","by", or the appropriate "apply" to perform a function on data with more than one factor on unbalanced data... I have a data frame in the long format that does not contain balanced data. The ID is a unique identifier correspon

Re: [R] how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work

2007-03-07 Thread jim holtman
Here is one way of doing it: > # create the rows for each unique combination > x.split <- split(seq(nrow(mydata)), list(mydata$time, mydata$treatment, + mydata$expREP, mydata$techREP), drop=TRUE) > # now go through the list of indices and add the median > mydata$Y50 <- 0 # add the dummy medi

Re: [R] how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work

2007-03-07 Thread Petr Pikal
On 7 Mar 2007 at 17:25, ALAN SMITH wrote: Date sent: Wed, 7 Mar 2007 17:25:54 -0600 From: "ALAN SMITH" <[EMAIL PROTECTED]> To: r-help@stat.math.ethz.ch Subject: [R] how to "apply" functions to unbal

Re: [R] how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work

2007-03-08 Thread ALAN SMITH
:00:53 +0100 From: "Petr Pikal" <[EMAIL PROTECTED]> Subject: Re: [R] how to "apply" functions to unbalanced data in long format by factors..cant get "by" or "aggregate" to work To: "ALAN SMITH" <[EMAIL PROTECTED]>, r-help@s

Re: [R] how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work

2007-03-08 Thread hadley wickham
> Hello R-users > The help I received from Petr helped me created this solution to my problems. > > t1<-with(mydata ,aggregate(mydata$Y, > list(mydata$time,mydata$treatment, mydata$expREP, mydata$techREP) , > median, na.rm=T)) ### find median by factors > > colnames(t1)<-c("time","treatment","