R error condition has length > 1 Hi i am getting this error:


  Error in if (x &lt; min) { : missing value where TRUE/FALSE needed
  In addition: Warning message:
  In if (x &lt; min) { :
    the condition has length > 1 and only the first element will be used


I have seen this error in others post but his solutions don't fix it,
I think this may be a different case

My code: 

min &lt;- data[1,2]

for(i in data){

  if(data[i,2] &lt; min){

    min &lt;- data[i, 2]

  }

}


The column that I am using(the second) all are numeric values

Thanks!
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])