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 NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

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

Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

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

There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.