Data preprocessing
In this section, we will be focusing on data preprocessing which includes data cleaning, transformation, and normalizations if required. Basically, we perform operations to get the data ready before we start performing any analysis on it.
Dealing with missing values
There will be situations when the data you are dealing with will have missing values, which are often represented as NA
in R. There are several ways to detect them and we will show you a couple of ways next. Note that there are several ways in which you can do this.
> # check if data frame contains NA values > sum(is.na(credit.df)) [1] 0 > > # check if total records reduced after removing rows with NA > # values > sum(complete.cases(credit.df)) [1] 1000
The is.na
function is really useful as it helps in finding out if any element has an NA
value in the dataset. There is another way of doing the same by using the complete.cases
function, which essentially returns a logical vector saying whether...