I have some issues to correctly return a variable within a function in R. In the following example, I've created a function for a Leave-One-Out Cross Validation. The problem is that the function doesn't seem to affect the variable 'mse' in any way, it remains as it was initially set up.
I tried to only run the script from the 'for' line and it works well, all the 'mse' values are added to the variable.
How come that by using a function, I cannot modify my variable? Is it related to the local/general variables or something?
Thank you.