Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between NaN and Inf, and NULL and NA in R?

Tags:

r

What is the difference between NaN and Inf, and NULL and NA in R?

Why ?NA and ?NULL tell me that "NA" has a length of "1" whereas NULL has a length of "0"?

like image 312
Igor Chubin Avatar asked Mar 19 '13 10:03

Igor Chubin


People also ask

What is the difference between Null Na NaN and INF values in R?

NA and “NA” (as presented as string) are not interchangeable. NA stands for Not Available. NaN stands for Not A Number and is a logical vector of a length 1 and applies to numerical values, as well as real and imaginary parts of complex values, but not to values of integer vector. NaN is a reserved word.

What is the difference between NaN and Na in R?

A NAN value in R represents “NOT A NUMBER”, It is basically any numeric calculations with an undefined result, such as '0/0'. This exists only in vectors with numeric datatype. A NA value in R represents "NOT AVAILABLE". This can exist in any sort of numeric or character vectors.

What is the difference between NA and null in R?

In simple words, NULL represents the null or an empty object in R. NA represents a missing value in R. NA can be updated in R by vectors, list and other R objects whereas NULL cannot be coerced.

Is NaN and null the same thing?

NaN : means 0/0 -- Stands for Not a Number NA : is generally interpreted as a missing, does not exist NULL : is for empty object.


2 Answers

In short

NaN  : means 0/0 -- Stands for Not a Number NA   : is generally interpreted as a missing, does not exist NULL : is for empty object. 

For an exact definition, you can read the documentation, which is very well written.

like image 93
agstudy Avatar answered Sep 24 '22 21:09

agstudy


In R language, there are two closely related null-like values: NA and NULL. Both are used to represent missing or undefined values.

NULL represents the null object, it's a reserved word. NULL is perhaps returned by expressions and functions, so that values are undefined.

NA is a logical constant of length 1, which contains a missing value indicator. NA can be freely coerced to any other vector type except raw. There are also constants NA_integer_, NA_real_, NA_complex_ and NA_character_ of the other atomic vector types which support missing values: all of these are reserved words in the R language.

like image 42
Mumtaz Ahmad Avatar answered Sep 20 '22 21:09

Mumtaz Ahmad