Re: [R] matrix manipulations

2011-01-18 Thread Petr Savicky
On Mon, Jan 17, 2011 at 10:37:42PM +, Monica Pisica wrote: > > Hi, > > I've got 2 very good solutions, thank you very much. One, from Henrique > Dallazuanna using the library reshape and one line of code - although it will > take me quite some time to understand it. Here it is what he sent:

Re: [R] matrix manipulations

2011-01-17 Thread Monica Pisica
To: pisican...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] matrix manipulations > > Monica - > Perhaps this small example can demonstrate how factors can > solve your problem: > > > d1 = > > data.frame(cat=sample(c('cat2','c

Re: [R] matrix manipulations

2011-01-17 Thread Henrique Dallazuanna
Try this: library(reshape) xtabs(rowSums(cbind(value.x, value.y), na.rm = TRUE) ~ X1 + X2, merge(melt(m1), melt(m2), by = c('X1', 'X2'), all = TRUE), exclude = FALSE) On Mon, Jan 17, 2011 at 5:59 PM, Monica Pisica wrote: > > Hi, > > I am having some difficulties with matrix operations. It is a

Re: [R] matrix manipulations

2011-01-17 Thread Phil Spector
Monica - Perhaps this small example can demonstrate how factors can solve your problem: d1 = data.frame(cat=sample(c('cat2','cat5','cat6'),100,replace=TRUE),group=sample(c('land','water'),100,replace=TRUE)) d2 = data.frame(cat=sample(c('cat1','cat3','cat4'),100,replace=TRUE),group=sample(c(

[R] matrix manipulations

2011-01-17 Thread Monica Pisica
Hi, I am having some difficulties with matrix operations. It is a little hard to explain it so please bear with me. I have a very large data set, large enough that it needs to be split in parts in order to deal with. I can work things on these "parts" but the problem lies in adding together th