Re: [R] Data.frame manipulation

2010-01-29 Thread AC Del Re
Thanks again, Dennis and Petr! The solution using the plyr package was perfect: ddply(data, .(id, mod1), summarize, es = mean(es), mod2 = head(mod2, 1)) Take care, AC On Thu, Jan 28, 2010 at 11:26 PM, Petr PIKAL wrote: > Hi > > r-help-boun...@r-project.org napsal dne 28.01.2010 17:40:01: > >

Re: [R] Data.frame manipulation

2010-01-28 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 28.01.2010 17:40:01: > Thank you, Dennis and Petr. > > One more question: when aggregating to one es per id, how would I go about > keeping the other variables in the data.frame (e.g., keeping the value for > the first row of the other variables, suc

Re: [R] Data.frame manipulation

2010-01-28 Thread Dennis Murphy
Hi: On Thu, Jan 28, 2010 at 8:40 AM, AC Del Re wrote: > Thank you, Dennis and Petr. > > One more question: when aggregating to one es per id, how would I go about > keeping the other variables in the data.frame (e.g., keeping the value for > the first row of the other variables, such as mod2)

Re: [R] Data.frame manipulation

2010-01-28 Thread AC Del Re
Thank you, Dennis and Petr. One more question: when aggregating to one es per id, how would I go about keeping the other variables in the data.frame (e.g., keeping the value for the first row of the other variables, such as mod2) e.g.: # Dennis provided this example (notice how mod2 is removed f

Re: [R] Data.frame manipulation

2010-01-28 Thread AC Del Re
Thank you Dennis--this is perfect!! AC On Thu, Jan 28, 2010 at 12:24 AM, Dennis Murphy wrote: > Hi: > There are several ways to do this, but these are the most commonly used: > aggregate() and the ddply() function in package plyr. > > (1) plyr solution (using x as the name of your input data fr

Re: [R] Data.frame manipulation

2010-01-27 Thread Petr PIKAL
HI r-help-boun...@r-project.org napsal dne 28.01.2010 04:35:29: > > Hi All, > > > > I'm conducting a meta-analysis and have taken a data.frame with multiple > > rows per > > study (for each effect size) and performed a weighted average of effect > > size for > > each study. This results in a re

Re: [R] Data.frame manipulation

2010-01-27 Thread AC Del Re
> Hi All, > > I'm conducting a meta-analysis and have taken a data.frame with multiple > rows per > study (for each effect size) and performed a weighted average of effect > size for > each study. This results in a reduced # of rows. I am particularly > interested in > simply reducing the additiona

Re: [R] data.frame manipulation: Unbinding strings in a row

2008-01-10 Thread jim holtman
here is a quick hack: > x <- read.table(textConnection("ID ShopItems + ID1 A1 item1,item2,item3 + ID2 A2 item4,item5 + ID3 A1 item1,item3,item4"), header=TRUE) > y <- lapply(1:nrow(x), function(.row){ + .items <- strsplit(as.character(x$Items[.row]), ',')[[1