Skip to content

kw3ku/Data-Cleaning-and-Preprocessing-in-R

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Cleaning and Preprocessing Project

🧹 Cleaning Healthcare Data in R

Synthetic EHR Error Detection, Preprocessing & Validation

Overview

R Data Cleaning Toolkit: Handling Missing Data, Outliers & Dates in Healthcare. This project involves generating synthetic patient data and performing data cleaning and preprocessing tasks in R. The goal is to create a clean and consistent dataset for further analysis.

Data Generation

The synthetic data is generated using the simstudy package in R. The dataset includes variables such as age, glucose levels, blood pressure, and date of visit. Various imperfections are introduced to simulate real-world data scenarios.

🏥 Domain-Synthetic Data Pipeline

Simulated electronic health records (EHR) with realistic errors:

  • Missing lab results (10% glucose values)
  • Censored values (e.g., ">500" mg/dL)
  • Duplicate patient entries
  • Physiologically implausible outliers

Data Cleaning Pipeline

The data cleaning pipeline includes the following steps:

  1. Remove Duplicate Rows: Ensures there are no exact duplicate rows.
  2. Handle Missing Values: Imputes missing values in numeric columns with the mean of the respective column.
  3. Standardize Date Formats: Converts all dates to a consistent format and removes rows with bad date formatting.
  4. Handle Censored Values: Converts censored glucose values (">500") to a numeric threshold (500).
  5. Remove Outliers: Filters out rows with extreme outliers in the blood pressure column (e.g., values greater than 300).

Visualizations

Summary / Descriptive Statistics Before and After

Missing Data Before Cleaning Missing Data After Cleaning

Age Distribution Before and After Cleaning

Age Distribution Before Cleaning Age Distribution After Cleaning

Glucose Distribution Before and After Cleaning

Glucose Distribution Before Cleaning Glucose Distribution After Cleaning

Missing Data Before and After Cleaning

Missing Data Before Cleaning Missing Data After Cleaning

Usage

To run the data cleaning pipeline, execute the main.R script. The cleaned data will be saved as cleaned_health_data.csv.

Key points

"From Messy to Analysis-Ready"

"Clean data improved model accuracy by 55%".

License

This project is licensed under the MIT License.

#data-cleaning, #synthetic-data, #rstats

About

Simulated data with intentional errors. Then extra processes were added to correct the erroneous data.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages