Update: The R2 function is deprecated.
You can get R2 by the postResample function now.
The code is here and shows in line 136 and 142 the formula:
resamplCor <- try(cor(pred, obs, use = "pairwise.complete.obs"), silent = TRUE
out <- c(sqrt(mse), resamplCor^2, mae)
So postResample uses the squared correlation to calculate R2.
Best case you predefine your indices via createMultiFolds.
Its important that by default - if "cv" selected instead of "repeatedcv" or repeates not defined in trainControl - there won't be repeates.
So, you have to predefine you multifold indices then set the number of repeates in the trainControl.
k - number of the folds will be automatically recognized ...