This is a great post by Nick Horton not only for the example R (and SAS) code, but also because of the useful statistics lesson. Here's his intro:
"Simpson's paradox is always amazing to explain to students. What's bad for one group, and bad for another group is good for everyone, if you just collapse over the grouping variable. Unlike many mathematical paradoxes, this arises in a number of real-world settings."