[R] Grouping sets of data, performing function and re-assigning values

2010-08-27 Thread Johnny Tkach
Hi there, I hope you have time to read this question and offer a suggestion or two. My basic question is this: I have data in sets of three. I would like to combine the data from each set, perform a function (probably just taking the median and MAD), then re-assign these values to each of

Re: [R] Grouping sets of data, performing function and re-assigning values

2010-08-27 Thread Johnny Tkach
Hi all, Since I could not attach a file to my original e-mail request, for those who want to look at an example of a data file I am working with, please use this link: http://dl.dropbox.com/u/4637975/exampledata.csv Thanks again, Johnny. __

Re: [R] Grouping sets of data, performing function and re-assigning values

2010-08-27 Thread Ista Zahn
Hi Johnny, If I understand correctly, I think you can use cut() to create a grouping variable, and then calculate your summaries based on that. Something like dat - read.csv(~/Downloads/exampledata.csv) dat$image.group - cut(dat$a.ImageNumber, breaks = seq(0, max(dat$a.ImageNumber), by = 3))

Re: [R] Grouping sets of data, performing function and re-assigning values

2010-08-27 Thread Johnny Tkach
HI Ista, Thanks for the help. The 'cut' function seems to do the trick . I'm not sure why you suggested this line of code: ddply(dat, .(image.group), transform, measure.median = median(Measurement)) I think I might have confused the issue by putting a 'Measurement' column in my example in

Re: [R] Grouping sets of data, performing function and re-assigning values

2010-08-27 Thread Joshua Wiley
Hi Johnny, Something like this rbind(NA, dat.med)[as.numeric(dat$image.group), ] should do the trick (with the data you provided and Ista's code). The key is that dat.med has a different row for each level of the factor image.group (and in the same order). The idea is to convert the factor