I am having a little problem with R and I am not sure why. It is telling me that this line: if(temp > data[[k]][[k2]]) { is of argument length 0. Here is the
if(temp > data[[k]][[k2]]) {
The simplest solution to the problem is to change your for loop statement :
Instead of using
for (i in **0**:n))
Use
for (i in **1**:n))