Re: [R] Converting data frame to symmetric matrix

2009-01-08 Thread poastpd
Thank you. It worked! Quoting Henrique Dallazuanna : Try this: reshape(d, timevar = "x", idvar = "y", direction = "wide") On Tue, Jan 6, 2009 at 6:29 AM, wrote: Dear Sir or Madam, I have the following data frame (which is just a toy example of my larger dataset) L3 <- LETTERS[1:3] x=c(1

Re: [R] Converting data frame to symmetric matrix

2009-01-06 Thread jim holtman
try this: L3 <- LETTERS[1:3] x=c(1,1,2,2,3,3,4,4,5,5) y=1:10 d <- data.frame(cbind(x,y), fac=I(sample(L3, 10, replace=TRUE))) m.out <- matrix(ncol=10, nrow=10) m.out[cbind(d$x, d$y)] <- d$fac On Tue, Jan 6, 2009 at 3:29 AM, wrote: > Dear Sir or Madam, > > I have the following data frame (which

Re: [R] Converting data frame to symmetric matrix

2009-01-06 Thread Henrique Dallazuanna
Try this: reshape(d, timevar = "x", idvar = "y", direction = "wide") On Tue, Jan 6, 2009 at 6:29 AM, wrote: > Dear Sir or Madam, > > I have the following data frame (which is just a toy example of my larger > dataset) > > L3 <- LETTERS[1:3] > x=c(1,1,2,2,3,3,4,4,5,5) > y=1:10 > d <- data.frame(