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
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
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
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
4 matches
Mail list logo