https://medium.com/@adrian.joseph/everything-you-want-to-know-about-the-r-apply-functions-60de9ec63c84