Re: [R] How to a handle an error in a loop

From: Farrel Buchinsky <>
Date: Tue 09 May 2006 - 08:57:16 EST

"Seth Falcon" <> wrote in message news:m2bquaei4x.fsf@ziti.local...
> If you want to do more than one thing, you want to create an anonymous
> function. Here's an example:
Thanks for the example. Between what you did and some reading that I did I have got a vague idea of how to use the {} curly brackets and how to create functions. It appears that the "function()" function together with the curly brackets allows one to put several command lines into one location. It allows one to overcome the problem of stuffing 3 lines into one spot as I had asked earlier.

I will confess that I have not tried your solution (although it appears to be very elegant and efficient). Instead, immediately after posting my questions, I persevered with my "for" loop that was able to print out a whole series of "works" but would print the number of the column that caused an error (see earlier post in this thread). I then rand the whole data frame through the loop. I then scrolled through the output buffer and noted which columns had a problem. There were about 15 or 20 columns. I simply named them in a c() function. From that point on it was "Heaven on Earth" from a statistical analysis point of view. I ran the lapply function with the tdt function in it and I was easily able to pass on the whole dataframe but exclude the columns that either did not have genotyping information in it or had information that I knew would cause an error.

I performed almost 6000 tdt tests serially and output all the information to a named object. In turn, that named object could be summarized and interrogated.
If anybody wants more information, then feel free to contact me.

My thoughts on R: incredibly powerful, incredibly flexible, very steep learning curve but thanks to people on this mailing list and thanks to David Clayton it was all doable. As I have become more proficient with R so I am better able to help others in my center. It is quite paradoxical that since R is open source there is no official technical support, yet when I needed help it was more rapid and more insightful then anything I have ever experienced with commercial software.

Farrel Buchinsky mailing list PLEASE do read the posting guide! Received on Tue May 09 09:18:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 May 2006 - 12:10:00 EST.

Mailing list information is available at Please read the posting guide before posting to the list.