https://machinelearningmastery.com/logic-flow-control-and-functions-in-r/