MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# What is the difference between NA and NAN in R?

# What is the difference between NA and NAN in R?

This recipe explains what is the difference between NA and NAN 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. It is generally interpreted as missing values.

Even one NAN or NA value in a vector causes difficulty to carry out calculations. Hence, we need to remove or replace it before carrying out any calculation. Before we actually remove or replace them, we need to check whether there is an NAN or NA number in a vector and for this we use is.nan() and is.na() function.

This recipe demonstrates how to find if a vector has NAN or/and NA values.

We create two vectors, one with NAN values and the other with NA.

```
a = c(2,5,8,20,NaN, 35,NaN)
b = c(2,5,8,20,75,35,100, NA)
```

We use any() along with is.nan() and is.na() function to check for NaN and NA values.

The function is.nan() is used to check specifically for NaN but is.na() also returns TRUE for NaN.

1. Checking in a

```
#checking for NaN values in "a" vector
any(is.nan(a))
```

TRUE

#checking for NA values in "a" vector any(is.na(a))

TRUE

Note: Both of the condition has returned TRUE. That means there is NAN or NA values present in "a" vector

2. Checking in b

```
#checking for NaN values in "b" vector
any(is.nan(b))
```

FALSE

#checking for NA values in "b" vector any(is.na(b))

TRUE

Note: any(is.na()) is True which means there is NA values present in "a" vector nut no NAN values

In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset using Keras in Python.

Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.