October 2, 2019

Loops

We have looked at basic looping with for(). See pages 104-105.

And we have discussed the apply() function. See pages 106-107.

Now we will discuss some further examples of related apply() functions.

- sapply()
- lapply()

sapply() and lapply()

These are different from the apply() function. The apply() function works with vectors and matricies.

The lapply() function works with lists. So it expects a list and returns a list.

And the sapply() is a bit simpler in that it takes what it gets and trys to return the simplest structure it can.

Some Examples of sapply() and lapply()

See pages 106-109.

Dates

Dates are often values when read into R.

We will need to convert them to dates.