Re: [R] rtree() distances between tips as n by n matrix?

2011-03-29 Thread Brian Pellerin
Thanks, Simon. This is very useful. Brian On Mon, Mar 28, 2011 at 11:39 PM, Simon Blomberg wrote: > ?cophenetic > > Cheers, > > Simon. > > On 29/03/11 10:27, Ben Bolker wrote: > >> Brian Pellerin gmail.com> writes: >> >> >> >> >>

[R] rtree() distances between tips as n by n matrix?

2011-03-28 Thread Brian Pellerin
Hello R users, If I generate a random tree with n=10 tips as rtree(n=10) say, is there a way to have the distances between all tips put into a n by n matrix? Sincerely, Brian [[alternative HTML version deleted]] __ R-help@r-project.org mailing

Re: [R] Building a matrix so that matrix(r, c)<-matrix(c, r) with No For Loops

2011-03-26 Thread Brian Pellerin
Thanks, David. This works splendidly. Thanks for your help. Sincerely, Brian >>> David Winsemius 03/26/11 3:06 PM >>> On Mar 26, 2011, at 9:44 AM, Brian Pellerin wrote: > Hello, > > I would like to take advantage of the upper.tri() function here but > I don&

[R] Building a matrix so that matrix(r, c)<-matrix(c, r) with No For Loops

2011-03-26 Thread Brian Pellerin
Hello, I would like to take advantage of the upper.tri() function here but I don't know exactly. Here is some working code... i<-5 fi<-matrix(0,nrow=i,ncol=i) for(r in 1:i){ for(c in 1:i){ if(r==c){ fi[r,c]<-1 }else if(rhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] Matrix building to remove for loops

2011-03-16 Thread Brian Pellerin
Thanks, we're almost there. The 3rd statement needs to satisfy fi_2[r,c]<-fi_2[c,r] where rwrote: > Try this: > > fi_2 <- diag(1, i) > fi_2[lower.tri(fi_2)] <- 1 - runif(sum(lower.tri(fi_2))) ^ .5 > fi_2[upper.tri(fi_2)] <- fi_2[lower.tri(fi_2)] > > On Tue, M

[R] Matrix building to remove for loops

2011-03-15 Thread Brian Pellerin
Hello R users, I would like to reduce the number of for loops in my code. I build these matrices (5 times). The main diagonal are 1s and the two sides along the main diagonal mirror each other as follows: i<-5 fi<-matrix(0,nrow=i,ncol=i)#floral inhibition matrix for(r in 1:i){ for(c in 1:i){