12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

NaN in calculations. The outcome of those calculations is always NaN, though, as yousee here:> NaN + 4[1] NaNYou can test whether a calculation results in NaN by using the is.nan()function. Note that both is.finite() and is.infinite() return FALSE when you’retesting on a NaN value.Dealing with missing valuesAs we mention earlier in this chapter, one of the most common problems instatistics is incomplete data sets. To deal with missing values, R uses the reservedkeyword NA, which stands for Not Available. You can use NA as a valid value, so youcan assign it as a value as well:> x x + 4[1] NA> log(x)[1] NAIf you want to test whether a value is NA, you can use the is.na() function, asfollows:> is.na(x)[1] TRUENote that the is.na() function also returns TRUE if the value is NaN. Thefunctions is.finite(), is.infinite(), and is.nan() return FALSE for NA values.Calculating infinite, undefined, and missing valuesTable 4-3 provides an overview of results from the functions described in the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!