[R] for (n in SystemResults$EnTime) return EnTime[n] until reaching "(all)"

David Winsemius dwinsemius at comcast.net
Sun Jul 12 22:05:50 CEST 2009


On Jul 12, 2009, at 3:35 PM, David Winsemius wrote:

>
> On Jul 12, 2009, at 2:53 PM, Mark Knecht wrote:
>
>>
>>  As a test I tried to print down to the string "(all)" and then
>> break but this code and everything I've tried so far is terribly
>> wrong. Every attempt prints lots of error messages. I'm not grasping
>> at all what I'm doing wrong or what's the right way to do this sort  
>> of
>> thing. Clearly my first for loop isn't a success!
>>
>> for(n in SystemResults$EnTime)  {
>> 	if(SystemResults$EnTime[n] == "(all)") break)
>
> Inside the loop, shouldn't you be comparing to "n"?? As you have it  
> now, the values of that factor are probably being used as indices to  
> itself. (Not good.) Also not good is the use of "break".  It looks  
> to be fairly severely deprecated at this point

Appears I am wrong about this. I was basing my assumption on this  
interaction with the R interpreter:
 > ?break
Error in genericForPrimitive(f) :
   methods may not be defined for primitive function "break" in this  
version of R

But:

?Control ... suggests that break-ing out of for loops remains  
acceptable.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list