Thanks Marco,

sorry if my explanation was not the best, but your code did the trick.
 I managed to adjust the code to get exactly what I wanted.

Thank you!

Luisa


On Mon, May 30, 2011 at 4:20 PM, Jabba <jabbba@gmail.com> wrote:

> Hi Luisa,
>
> it was really difficult to manage to understand what you need. Assuming
> that i've done it correctly this should be similar to what you want:
>
> A.matrix <- matrix(rpois(n=28,lambda=2),nrow=7)
>
> M.matrix <- matrix(0,nrow=dim(A.matrix)[2],ncol=dim(A.matrix)[2])
> for(i in 1:dim(df)[2])
>  for(j in i:dim(df)[2]) {
>  prod <- df[,i]*df[,j]
>  M.matrix[i,j] <- length(which(prod!=0))
>  }
>
> sums <- apply(A.matrix,2,sum)
> N.matrix <- matrix(0,nrow=dim(A.matrix)[2],ncol=dim(A.matrix)[2])
> > for (i in 1:length(sums))
>  for (j in i:length(sums)){
>  diff <- sums[i]-sums[j]
>  N.matrix[i,j] <- diff
>  }
>
> I briefly searched a way to to this without cycling inside objects, but
> i wasn't able to do it straightforwardly. Probably somebody could
> give a more efficient and simple hint.
>
> Marco.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

