Customer Segmentation Using R Programming
Customer Segmentation Using R Programming 1. IMPORT DATA data <-read.csv("C:/Users/aishw/Downloads/train-set.csv") head(data) str(data) summary(data) This R code explores a CSV file. It reads the data (read.csv), previews the first few rows (head), examines the data structure (str), and summarizes the data (summary) to give you a quick understanding of what you're working with before further analysis. 2. DATA PREPROCESSING {r} cleaned_data <- data[complete.cases(data), ] print("Cleaned Dataframe:") print(cleaned_data) data=cleaned_data This code cleans the data by removing rows with missing values and then replaces the original data with the cleaned version. This is often a crucial step in data analysis, as missing values can lead to errors or inaccuracies in calculations and modeling. By cleaning the data, you ensure a more reliable foundation for further analysis. 3. K-MEANS CLUSTERING {r} if (!is.data.frame(data)) { ...