Dear all,

I want to do a loop with foreach. But, I would like to include a condition
with "next" to don't loop over some elements.

For example, I would like to translate this "for loop" to a "foreach loop":

for (i in 1:10) {
  for (j in 1:2) {
  ...
  if((i==2 & j==1) | (i==4 & j==3)) { next }
  ...
  }
}

Foreach loop???

foreach (i = c(1:10)) %do%{
  foreach (j = c(1:2)) %do%{

#I don't know how to include a "next"!!
...

  }
}

Thank you!

Marc

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to