[R] breaking a loop in R
NatsS
nsahgal at well.ox.ac.uk
Fri Jul 3 18:45:47 CEST 2009
Hello,
Please could someone explain
break and next??
Is there a way to break a loop that is not the innermost loop??
for example:
#=========================
dim A = 1000 x 3
dim B = 2000 x 3
for (a in 1:1000){
for (b in 1:2000){
expr = intersect(A[a,1]:A[a,2],B[b,1]:B[b,2])
if (!is.na(expr[1])){
indx = which(expr[1] >= A[,2])
if (length(indx) > 1){
for(c in 1:length(indx))
X[a,1] = paste(.....)
.....
}else {
X[a,1] = A[indx, 3]
}
}
###BREAK - Here does not work
NEXT # am not sure if this is doing what I want it to??
}
}
#=============================
Any help and advice would be much appreciated!
Many Thanks,
NS
--
View this message in context: http://www.nabble.com/breaking-a-loop-in-R-tp21322868p24325853.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list