In R programming, NA is a logical constant used denote a missing value. The length of NA is
In this tutorial, we will learn what NA is in R programming, how to assign NA to a variable, and how to check if a value is NA or not.
Assign NA to a Variable
To assign NA to a variable
x, use the following syntax.
x <- NA
Check if Value is NA
To check if a value stored in a variable
x is NA, use the following expression.
In the following program, we will assign NA to a variable
x. We shall programmatically check if
x is having missing value
NA or not.
x <- NA print(is.na(x))
If x is a list, then is.na(x) returns
FALSE for each item in the list.
In the following program, we will create a list with some values, and programmatically check if these are NA or not.
x <- list("Hello", NA) print(is.na(x))
 FALSE TRUE
Check if there is any NA
We can check if there is any NA in given atomic vector, list, or pairlist.
In the following program, we will take a list where an element is NA. anyNA must return TRUE, since there is at least one NA in the list.
x <- list("Hello", NA) print(anyNA(x))
Length of NA
NA has a length of
1. Let us print the length of NA to output using length() function.
x <- NA print(length(x))
In this R Tutorial, we learned how to find the minimum value of given arguments using
min() function, with the help of examples.