Re: [R] how to generate a matrix by an my data.frame

2013-01-10 Thread Yao He
Thanks a lot it works! 2013/1/11 Rui Barradas : > Hello, > > Here are two ways. > > dat <- read.table(text = " > > id1id2 value > 2353 2353 0.096313 > 2353 2409 0.301773 > [...etc...] > > 2356 2356 0 > 2356 2611 0 > 2611 2611 0 > ", header = TRUE) > > mat1 <- matrix

Re: [R] how to generate a matrix by an my data.frame

2013-01-10 Thread Rui Barradas
Hello, Here are two ways. dat <- read.table(text = " id1id2 value 2353 2353 0.096313 2353 2409 0.301773 [...etc...] 2356 2356 0 2356 2611 0 2611 2611 0 ", header = TRUE) mat1 <- matrix(nrow = 53, ncol = 53) # initialize with NA's mat1[upper.tri(mat1, diag = TRUE)