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
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,expREP,techREP,Y50)

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

[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 corresponding

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 median

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
Hi you can use aggregate to create table of medians with(mydata, aggregate(Y, list(time, tratment, expRep,), median) repeats of unique factors either by rle or aggregate with length function Then you can do replication by norep - rep(your.median, each = your replicates) Regards Petr On