Dear all, I would like to capture the NA values as produced from my code the str over the return values return int 61 int 65 int 69 int 73 int 101 int NA int NA it looks like that I am getting returned some integer values that are NA and I want to have an if statement for catching those which is the right operator for checking these int NA values in R? Alex [[alternative HTML version deleted]]
On 10-05-2012, at 17:16, Alaios wrote:> Dear all, > I would like to capture the NA values as produced from my code > the str over the return values return > > int 61 > int 65 > int 69 > int 73 > int 101 > int NA > int NA > > it looks like that I am getting returned some integer values that are NA and I want to have an if statement for catching those > > which is the right operator for checking these int NA values in R?How about simply is.na? Berend
On May 10, 2012, at 11:16 AM, Alaios wrote:> Dear all, > I would like to capture the NA values as produced from my code > the str over the return values return > > int 61 > int 65 > int 69 > int 73 > int 101 > int NA > int NA > > it looks like that I am getting returned some integer values that > are NA and I want to have an if statement for catching those > > which is the right operator for checking these int NA values in R?If you have a vector of mode 'integer' (or numeric) you can get their index locations with: which(is.na(vec)) Logical tests for any NA's would be: !length(which(is.na(vec))) or sum(is.na(vec))==0 or perhaps the most self-documenting method: any(is.na(vec)) -- David Winsemius, MD Heritage Laboratories West Hartford, CT