Advertisement

Loops and Functions

  • Alain F. Zuur
  • Elena N. Ieno
  • Erik H. W. G. Meesters
Chapter
Part of the Use R! book series (USE R)

When reading this book for the first time, you may skip this chapter, as building functions1 and programming loops2 are probably not among the first R procedures you want to learn, unless these subjects are your prime interests. In general, people perceive these techniques as difficult, hence the asterisk in the chapter title. Once mastered, however, these tools can save enormous amounts of time, especially when executing a large number of similar commands.

Introduction to Loops

One of R’s more convenient features is the provision for easily making your own functions. Functions are useful in a variety of scenarios. For example, suppose you are working with a large number of multivariate datasets, and for each of them you want to calculate a diversity index. There are many diversity indices, and new ones appear regularly in the literature. If you are lucky, the formula for your chosen diversity index has already been programmed by someone else, and, if you are very lucky, it is...

Keywords

Diversity Index Total Abundance Shannon Index Data Frame Error Message 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Copyright information

© Springer Science+Business Media, LLC 2009

Authors and Affiliations

  • Alain F. Zuur
    • 1
  • Elena N. Ieno
    • 1
  • Erik H. W. G. Meesters
    • 2
  1. 1.Highland Statistics Ltd.NewburghUK
  2. 2.IMARES, Institute for Marine Resources & Ecosystem Studies1797 SH ’t HorntjeThe Netherlands

Personalised recommendations