I have the summation below which have done successfully using for loops.
F <- matrix(c(2,3,4,5),nrow=2) ans=0 for (k in 1:2){ for (i in 1:2){