hi all, Assume I have data like data<-rbind(c(1,2),c(1,3),c(2,1),c(3,2),c(3,4)) I want to get some matrix like 1,2,3 2,NA,NA 3,2,4 I'm using by mat<-matrix(NA,3,3) by(data,data[,1],mat[data[,1],]<-c(data[,2])) but it doesn't work. Any ideas? thanks, cowboy