How to Use is.na in R? Last Updated : 02 Feb, 2022 Comments Improve Suggest changes Like Article Like Report In this article we will discuss how to use is.na in R programming language. is.na is used to check NA values present in the given data and return TRUE if the value is NA, otherwise FALSE Syntax: is.na(data) where, data is a vector/dataframe is.na() can be used with other methods to add more meaning to the requirement. To count the total NA values present in the data we have to use the sum() function Syntax: sum(is.na(data)) To get the positions where NA values are there, by using which() function Syntax: which(is.na(data))Use of is.na in vector A vector is a data structure that can store elements of multiple data types. Example: R program to get and count NA values in a vector R # create a vector data = c(1, 2, 3, NA, 45, 34, NA, NA, 23) # display print(data) # get NA values print(is.na(data)) # count NA values print(sum(is.na(data))) # get the NA index positions print(which(is.na(data))) Output: [1] 1 2 3 NA 45 34 NA NA 23 [1] FALSE FALSE FALSE TRUE FALSE FALSE TRUE TRUE FALSE [1] 3 [1] 4 7 8 Use of is.na in dataframe A dataframe is a data structure that can stores elements of multiple data type in rows and columns Example: R program to count NA and get NA values in a dataframe R # create a dataframe with 3 columns data=data.frame(column1=c(1,2,NA,34), column2=c(NA,34,56,NA), column3=c(NA,NA,32,56)) # display print(data) # get NA values print(is.na(data)) # count NA values print(sum(is.na(data))) # get the NA index positions print(which(is.na(data))) Output: We can use sapply() function to get total NA values in the dataframe. Syntax: sapply(dataframe, function(variable) sum(is.na(variable))) where dataframe is the input dataframefunction is to get sum of NA in each column Example: Use of is.na on a dataframe R # create a dataframe with 3 columns data=data.frame(column1=c(1,2,NA,34), column2=c(NA,34,56,NA), column3=c(NA,NA,32,56)) # display print(data) # get count of NA in each column print(sapply(data, function(x) sum(is.na(x)))) Output: Comment More infoAdvertise with us Next Article How to Use is.na in R? sravankumar_171fa07058 Follow Improve Article Tags : R Language R-basics Similar Reads How to Use "Is Not NA" in R? In this article, we will discuss how to use Is Not NA in R Programming Language. NA is a value that is not a number. The is.na() method is used to check whether the given value is NA or not, we have to use the function for this. Inorder to use is NOT Â NA, then we have to add the "!" operator to the 2 min read How to Use na.rm in R? In this article, we will discuss how to use na.rm in R Programming Language. na.rm in R is used to remove the NA values. na.rm in vector When we perform any operation, we have to exclude NA values, otherwise, the result would be NA. Syntax: function(vector,na.rm) where vector is input vectorna.rm is 3 min read How to Use na.omit in R? What are missing values?In data analysis, missing values refer to the absence of data for a particular variable or observation. These missing values are typically represented by a special symbol or code, often denoted as "NA" (Not Available) in R and many other programming languages. na.omit() funct 2 min read How to Use the (?) Operator in R The ? operator in R is a simple yet powerful tool that provides quick access to documentation and help pages for functions, datasets, and other objects within the R environment. Understanding how to effectively use this operator can significantly enhance your productivity and help you learn R Progra 4 min read How to Include NA in ifelse() Using R? The if-else () function in R is a powerful and efficient way to apply conditional logic across vectors, matrices, or data frames. However, dealing with NA (missing values) in if-else () can be tricky. This article will explore how to handle and include NA values effectively when using if-else () in 3 min read How to Use Nrow Function in R? In this article, we will discuss how to use Nrow function in R Programming Language. This function is used in the dataframe or the matrix to get the number of rows. Syntax: nrow(data) where, data can be a dataframe or a matrix. Example 1: Count Rows in Data Frame In this example, we are going to cou 2 min read How to Use read.delim in R? In this article, we will learn how to use the read.delim() in the R Programming Language. Example 1: Using read.delim() function to read a space-separated text file The read.delim() function is used to read delimited text files in the R Language. It doesn't need any external package to work. This fu 3 min read How to find missing values in a list in R Missing values are frequently encountered in data analysis. In R Programming Language effectively dealing with missing data is critical for correct analysis and interpretation. Whether you're a seasoned data scientist or a new R user, understanding how to identify missing values is critical. In this 3 min read How to Select Rows with NA Values in R In this article, we will examine various methods to select rows with NA values in the R programming language. What are NA values?NA represents 'not available' used for indicating the missing values or undefined data in the datasets. It is a logical constant of length 1. NA is one of the reserved wor 4 min read How the 'NA' Values are Treated in glm in R Generalized Linear Models (GLMs) are a versatile statistical modeling technique used for analyzing various types of data, including continuous, binary, count, and categorical responses. When working with real-world datasets, missing values ('NA' or 'NaN') are a common occurrence and need to be appro 5 min read Like