R error condition has length > 1
If you change your for loop to for(i in 1:nrow(data)){... then it will work.

I would not call your variable min because that is the name of the function which you should be using instead such as:

tmp=min(data[,2])