Warning Message Line Number R

You could try setting:

options(warn = 2)

... to treat warnings as errors. Then, when your code stops at the first warning, use traceback() to see the stack trace.

This will only help you with the first warning though.

To go back to the default behaviour, use:

options(warn = 0)

This is a basic for loop howto, not really R dependent

Right before your min line put

 print(paste("j is", j, "\n"))  # or instead of j, use i, or whichever index you are using     
 min(j, na.rm = TRUE) 

then you will have a good idea of where the error is.


As for a more R relevant solution, if j is coming from a data.frame, matrix, list, etc,
you want to find which chunk (iteration portion) has nothing but NAs.

For that you can use something like

  apply(myDF, 1, function(x) all(is.na(x)))

Tags:

R