On Tue, May 22, 2012 at 9:01 AM, jiangxijixzy <jiangxiji...@163.com> wrote: > The function I wrote can run well with the small data, but with the large > data, the function runs very very slowly. How can I correct it? Thank you > very much. My function as below: > I guess this is a classic loops vs vectorization problem.
> fortune('treat') Contrary to popular belief the speed of R's interpreter is rarely the limiting factor to R's speed. People treating R like C is typically the limiting factor. You have vector operations, USE THEM. -- Byron Ellis R-help (October 2005) I would suggest that you read up on vectorization in R to understand why it is often preferred to loops. Two obvious places are an Rnews article by John Fox (if I remember well) and his Companion to Applied Regression book. Moreover, please sign your messages with your real name. Regards Liviu ______________________________________________ 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.