O'Reilly logo

Learning R for Geospatial Analysis by Michael Dorman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automated calculations using the apply family of functions

In this section, you are going to learn about two very useful functions to apply an operation on the subsets of data. The two functions, tapply and apply, along with a few others, form a collection of functions called apply functions. The functions in the collection are used to apply (hence the name) a function we choose over subsets of an object, and then join the results to form a single object once again. The apply functions are a defining feature of R; they replace the necessity to write explicit loops in many common situations in data analysis, which makes the code shorter and more elegant.

Applying a function on separate parts of a vector

The tapply function is used to apply a function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required