R-Basic Part VI: Loop Functions and Debugging in R
Highlights Loop Functions - lapply, sapply, mapply, tapply and split in greater detail Debugging in R Introduction Loop functions are some of the most powerful functions in R language. They make it very easy to work in R, especially in an interactive setting. Writing for and/or while loops is useful when programming but not easy when working interactively on the command line. There are some functions use the ‘looping’ characteristics to ease coding. l a p p l y : Loops over a list and evaluate a function on each element. It’s a very general concept but can be efficiently used to conduct a lot of computations. s a p p l y : Same as l a p p l y but it provides a nicer, cleaner outputs a p p l y : Applies a function over the margins of an array. It is very useful if we want to summarize matrices, or other higher dimensional arrays. t a p p l y : Applies a function over subsets of a vector. A short form of the table apply. m a p ...