Skip to content
Prev 301652 / 398503 Next

R- Help (looping)

Hello,

Your code example doesn't make much sense, it needs decrypting. Let's see,

for(k in 1:length(c1)){
     if(c1[k] < lcl | c1[k] > ucl) {do something}
}

If this is it, then you can completely avoid the loop:

i1 <- c1 < lcl | c1 > ucl       # create an index vector
out.of.control <- c1[ i1 ]    # save the values

When you say you have a column, is it a matrix column? data.frame?
Give a data example with

dput( head(myData, 20) )   # paste the output of this in a post

Hope this helps,

Rui Barradas

Em 29-07-2012 21:59, Wellington G. Silva escreveu: