Skip to content

loop problem

2 messages · Muhammad Azam, Jim Lemon

#
Muhammad Azam wrote:
Hi Muhammad,
The first thing I would ask is "Why not store NULL in g2[[i]] if that 
element is NULL?". If you do this:

for(i in 1:P) {
 if(L > 1) {
  g1<-rep(NA,L)
  for(j in 1:(L-1)) g1[j]<-...
  g2[[i]]<-sort.list(g1)
 }
}

you will have fewer elements in g2 than you have sets of predictors and 
will then have to match up the sets of predictors with the elements in 
g2. I think you could just test for NULL

is.null(g2[[i]])

later on if you don't want to process these in a subsequent step.

Jim