Open noamross opened 9 years ago
I think the easiest way to teach this is to first show what the default behavior of mean
is on a numeric vector with a NA
. Then you could show how apply is a looping construct, so that the student learns to look at the function return object when they get output they didn't want. You could also use this to talk about anonymous functions.
https://github.com/noamross/zero-dependency-problems/blob/master/R/apply-with-na.md