[R] simple question on loop
billycorg
candilav at gmail.com
Fri Nov 16 17:01:36 CET 2012
Hi R Users.
I have a simple question on a loop.
The following loop works fine:
r_t=list()
for(i in 1:500)
{
r_t[[i]]=h_t_half[[i]]%*%matrix(*z_t_m*[i,])
}
But indeed I need also that *z_t_m* varies. Let us suppose that *z_t_m* has
1000 replicates,
I have written the following loop that (naturally) does not work.
r_t <- list()
for(r in 1:replicate)
{
for(i in 1:499)
{
r_t[[r]][[i]]=h_t_half[[i]]%*%matrix(*z_t_m*[[r]][i,])
}
}
If, for instance, I try to do
h_t_half[[1]]%*%matrix(*z_t_m*[[1000]][1,])
I effectively obtain (only one row of) r_t. But I need to have 1000
replications of the whole r_t, that has 500 rows.
Do you have any suggestions?
Thank you!!!
--
View this message in context: http://r.789695.n4.nabble.com/simple-question-on-loop-tp4649761.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list