I have the piece to display NAs, but I can't figure it out.
try(na.fail(x)) > Error in na.fail.default(x) : missing values in object # display NAs myvector[is.na(x)] # returns NA NA NA NA
The only thing I get from this the length of the NA vector, which is actually not too helpful when the NAs where caused by a bug in my code that I am trying to track. How can I get the index of NA element(s) ?
I also tried:
subset(x,is.na(x))
which has the same effect.
EDIT:
y <- complete.cases(x) x[!y] # just returns another NA NA NA NA
In R, missing values are represented by the symbol NA (not available). Impossible values (e.g., dividing by zero) are represented by the symbol NaN (not a number). Unlike SAS, R uses the same symbol for character and numeric data.
Use the square bracket operator with df[] notation to select rows by index in R, The syntax of this notation is df[rows, columns], replace rows with the index number, index range, or list of index values.
C Programming from scratch- Master C Programming An NA value in R represents “Not Available” that means missing value.
You want the which function:
which(is.na(arr))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With