Explained apply Functions in R with Examples