This is an extension of question on Function and looping in training and testing set using r. How to get the result of the function (func1) given below in e