Re: [R] repeating matrices in a list

2012-11-30 Thread arun
eating matrices in a list Suppose I have the following  square, non-negative matrices > g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T); I want to create a list where this matrix is repeated multiple times. if I do this brute force (manually), using > env <- list(g,g,g) works fine. Yields

Re: [R] repeating matrices in a list

2012-11-30 Thread arun
Hi, Try this: lapply(1:3,function(x) g) A.K. - Original Message - From: Anser Chen To: r-help@r-project.org Cc: Sent: Friday, November 30, 2012 12:50 PM Subject: [R] repeating matrices in a list Suppose I have the following  square, non-negative matrices > g=matri

Re: [R] repeating matrices in a list

2012-11-30 Thread Sarah Goslee
You are so close: rep(list(g), 3) [[1]] [,1] [,2] [,3] [1,] 0.00 2.04 [2,] 0.25 0.00 [3,] 0.00 0.60 [[2]] [,1] [,2] [,3] [1,] 0.00 2.04 [2,] 0.25 0.00 [3,] 0.00 0.60 [[3]] [,1] [,2] [,3] [1,] 0.00 2.04 [2,] 0.25 0.00 [3,] 0.00 0.60 Sa

[R] repeating matrices in a list

2012-11-30 Thread Anser Chen
Suppose I have the following square, non-negative matrices > g=matrix(c(0,2,4,0.25,0,0,0,0.6,0),3,3,byrow=T); I want to create a list where this matrix is repeated multiple times. if I do this brute force (manually), using > env <- list(g,g,g) works fine. Yields [[1]] [,1] [,2] [,3] [1