Sample data

# Load necessary libraries
library(tidyverse)
#;-) ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#;-) ✔ dplyr     1.1.4     ✔ readr     2.1.5
#;-) ✔ forcats   1.0.0     ✔ stringr   1.5.1
#;-) ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
#;-) ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
#;-) ✔ purrr     1.0.2     
#;-) ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#;-) ✖ dplyr::filter() masks stats::filter()
#;-) ✖ dplyr::lag()    masks stats::lag()
#;-) ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dlookr)
#;-) Registered S3 methods overwritten by 'dlookr':
#;-)   method          from  
#;-)   plot.transform  scales
#;-)   print.transform scales
#;-) 
#;-) Attaching package: 'dlookr'
#;-) 
#;-) The following object is masked from 'package:tidyr':
#;-) 
#;-)     extract
#;-) 
#;-) The following object is masked from 'package:base':
#;-) 
#;-)     transform
library(ggplot2)
library(rrcov)
#;-) Loading required package: robustbase
#;-) Scalable Robust Estimators with High Breakdown Point (version 1.7-5)

# Set seed for reproducibility
set.seed(10)

# Generate sample data
n <- 1000  # Number of observations

# Age between 18 and 90
age <- sample(18:90, n, replace = TRUE)

# Introduce errors in age column
age[sample(1:n, 50)] <- "InvalidAge"

# Workclass: Private, Self-emp-not-inc, Self-emp-inc, Federal-gov, Local-gov, State-gov, Without-pay, Never-worked
workclass <- sample(c("Private", "Self-emp-not-inc", "Self-emp-inc", "Federal-gov", "Local-gov", "State-gov", "Without-pay", "Never-worked"), n, replace = TRUE)

# Introduce missing values in workclass column
workclass[sample(1:n, 50)] <- NA

# Education: Bachelors, Some-college, 11th, HS-grad, Prof-school, Assoc-acdm, Assoc-voc, 9th, 7th-8th, 12th, Masters, 1st-4th, 10th, Doctorate, 5th-6th, Preschool
education <- sample(c("Bachelors", "Some-college", "11th", "HS-grad", "Prof-school", "Assoc-acdm", "Assoc-voc", "9th", "7th-8th", "12th", "Masters", "1st-4th", "10th", "Doctorate", "5th-6th", "Preschool"), n, replace = TRUE)

# Introduce inconsistencies in education column
education[sample(1:n, 50)] <- "InvalidEducation"

# Education Number: 1-16
education_num <- sample(1:16, n, replace = TRUE)

# Marital Status: Married-civ-spouse, Divorced, Never-married, Separated, Widowed, Married-spouse-absent, Married-AF-spouse
marital_status <- sample(c("Married-civ-spouse", "Divorced", "Never-married", "Separated", "Widowed", "Married-spouse-absent", "Married-AF-spouse"), n, replace = TRUE)

# Introduce missing values in marital_status column
marital_status[sample(1:n, 50)] <- NA

# Occupation: Tech-support, Craft-repair, Other-service, Sales, Exec-managerial, Prof-specialty, Handlers-cleaners, Machine-op-inspct, Adm-clerical, Farming-fishing, Transport-moving, Priv-house-serv, Protective-serv, Armed-Forces
occupation <- sample(c("Tech-support", "Craft-repair", "Other-service", "Sales", "Exec-managerial", "Prof-specialty", "Handlers-cleaners", "Machine-op-inspct", "Adm-clerical", "Farming-fishing", "Transport-moving", "Priv-house-serv", "Protective-serv", "Armed-Forces"), n, replace = TRUE)

# Introduce errors in occupation column
occupation[sample(1:n, 50)] <- "InvalidOccupation"

# Relationship: Wife, Own-child, Husband, Not-in-family, Other-relative, Unmarried
relationship <- sample(c("Wife", "Own-child", "Husband", "Not-in-family", "Other-relative", "Unmarried"), n, replace = TRUE)

# Introduce missing values in relationship column
relationship[sample(1:n, 50)] <- NA

# Race: White, Asian-Pac-Islander, Amer-Indian-Eskimo, Other, Black
race <- sample(c("White", "Asian-Pac-Islander", "Amer-Indian-Eskimo", "Other", "Black"), n, replace = TRUE)

# Introduce inconsistencies in race column
race[sample(1:n, 50)] <- "InvalidRace"

# Sex: Female, Male
sex <- sample(c("Female", "Male"), n, replace = TRUE)

# Introduce missing values in sex column
sex[sample(1:n, 50)] <- NA

# Capital Gain: 0-99999
capital_gain <- sample(0:99999, n, replace = TRUE)

# Introduce errors in capital_gain column
capital_gain[sample(1:n, 50)] <- -999

# Capital Loss: 0-99999
capital_loss <- sample(0:99999, n, replace = TRUE)

# Introduce errors in capital_loss column
capital_loss[sample(1:n, 50)] <- -999

# Hours per week: 1-99
hours_per_week <- sample(1:99, n, replace = TRUE)

# Introduce missing values in hours_per_week column
hours_per_week[sample(1:n, 50)] <- NA

# Native country: United-States, Cambodia, England, ...
native_country <- sample(c("United-States", "Cambodia", "England", "Puerto-Rico", "Canada", "Germany", "Outlying-US(Guam-USVI-etc)", "India", "Japan", "Greece", "South", "China", "Cuba", "Iran", "Honduras", "Philippines", "Italy", "Poland", "Jamaica", "Vietnam", "Mexico", "Portugal", "Ireland", "France", "Dominican-Republic", "Laos", "Ecuador", "Taiwan", "Haiti", "Columbia", "Hungary", "Guatemala", "Nicaragua", "Scotland", "Thailand", "Yugoslavia", "El-Salvador", "Trinadad&Tobago", "Peru", "Hong", "Holand-Netherlands"), n, replace = TRUE)

# Introduce missing values in native_country column
native_country[sample(1:n, 50)] <- NA

# Income: <=50K, >50K
income <- sample(c("<=50K", ">50K"), n, replace = TRUE, prob = c(0.75, 0.25))

# Create dataframe
sample_dirty_dataset <- data.frame(age, workclass, education, education_num, marital_status, occupation, relationship, race, sex, capital_gain, capital_loss, hours_per_week, native_country, income)

# Print first few rows of the dataset
head(sample_dirty_dataset)
#;-)   age        workclass  education education_num        marital_status
#;-) 1  26      Federal-gov Assoc-acdm             2             Separated
#;-) 2  72          Private    HS-grad            16    Married-civ-spouse
#;-) 3  89      Federal-gov    HS-grad            14 Married-spouse-absent
#;-) 4  71      Without-pay       12th             7                  <NA>
#;-) 5  56      Without-pay    5th-6th             5             Separated
#;-) 6  32 Self-emp-not-inc Assoc-acdm             4     Married-AF-spouse
#;-)          occupation   relationship               race    sex capital_gain
#;-) 1      Craft-repair  Not-in-family              Other Female        95729
#;-) 2 Machine-op-inspct      Unmarried Asian-Pac-Islander Female        16548
#;-) 3      Armed-Forces  Not-in-family              Black   Male        26865
#;-) 4 Machine-op-inspct           Wife Asian-Pac-Islander Female        80193
#;-) 5   Priv-house-serv Other-relative              Other   Male        97828
#;-) 6 InvalidOccupation        Husband              Black Female        76074
#;-)   capital_loss hours_per_week native_country income
#;-) 1        78233             71           Laos  <=50K
#;-) 2        91089             81          Italy  <=50K
#;-) 3         5355             51        Ecuador   >50K
#;-) 4        32043             64         Taiwan   >50K
#;-) 5        17804             47          Italy  <=50K
#;-) 6        28165             31          China  <=50K


summary(sample_dirty_dataset)
#;-)      age             workclass          education         education_num   
#;-)  Length:1000        Length:1000        Length:1000        Min.   : 1.000  
#;-)  Class :character   Class :character   Class :character   1st Qu.: 5.000  
#;-)  Mode  :character   Mode  :character   Mode  :character   Median : 9.000  
#;-)                                                           Mean   : 8.697  
#;-)                                                           3rd Qu.:13.000  
#;-)                                                           Max.   :16.000  
#;-)                                                                           
#;-)  marital_status      occupation        relationship           race          
#;-)  Length:1000        Length:1000        Length:1000        Length:1000       
#;-)  Class :character   Class :character   Class :character   Class :character  
#;-)  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
#;-)                                                                             
#;-)                                                                             
#;-)                                                                             
#;-)                                                                             
#;-)      sex             capital_gain    capital_loss   hours_per_week 
#;-)  Length:1000        Min.   : -999   Min.   : -999   Min.   : 1.00  
#;-)  Class :character   1st Qu.:21208   1st Qu.:21453   1st Qu.:23.25  
#;-)  Mode  :character   Median :45534   Median :46901   Median :49.00  
#;-)                     Mean   :47103   Mean   :47848   Mean   :49.75  
#;-)                     3rd Qu.:74322   3rd Qu.:74949   3rd Qu.:77.00  
#;-)                     Max.   :99692   Max.   :99804   Max.   :99.00  
#;-)                                                     NA's   :50     
#;-)  native_country        income         
#;-)  Length:1000        Length:1000       
#;-)  Class :character   Class :character  
#;-)  Mode  :character   Mode  :character  
#;-)                                       
#;-)                                       
#;-)                                       
#;-) 

Na_values_bool <- any(is.na(sample_dirty_dataset))#True

any(duplicated(sample_dirty_dataset))#No fully duplicated values
#;-) [1] FALSE

sum(is.na(sample_dirty_dataset))#300 missing values
#;-) [1] 300

nrow(sample_dirty_dataset)#1000
#;-) [1] 1000

sample_dirty_dataset <- na.omit(sample_dirty_dataset)

nrow(sample_dirty_dataset) #739
#;-) [1] 739

education_levels <- unique(sample_dirty_dataset$education)

#print(education_levels) #InvalidEducation


invalid_age_rows <- sample_dirty_dataset[sample_dirty_dataset$age == "InvalidAge", ]

print(invalid_age_rows)
#;-)            age        workclass        education education_num
#;-) 9   InvalidAge     Self-emp-inc       Assoc-acdm            10
#;-) 21  InvalidAge      Without-pay        Doctorate            15
#;-) 68  InvalidAge      Without-pay          5th-6th             6
#;-) 76  InvalidAge     Never-worked             11th            16
#;-) 117 InvalidAge     Never-worked              9th             6
#;-) 186 InvalidAge     Never-worked             10th            15
#;-) 189 InvalidAge        State-gov          Masters            13
#;-) 230 InvalidAge Self-emp-not-inc     Some-college             7
#;-) 232 InvalidAge     Self-emp-inc       Assoc-acdm             4
#;-) 288 InvalidAge        State-gov          HS-grad            14
#;-) 306 InvalidAge        Local-gov     Some-college             6
#;-) 321 InvalidAge Self-emp-not-inc             11th            10
#;-) 362 InvalidAge          Private             10th             7
#;-) 380 InvalidAge      Federal-gov          7th-8th             8
#;-) 406 InvalidAge     Self-emp-inc        Bachelors             1
#;-) 407 InvalidAge        State-gov        Bachelors            14
#;-) 449 InvalidAge        Local-gov        Assoc-voc             2
#;-) 450 InvalidAge        Local-gov              9th            11
#;-) 480 InvalidAge     Never-worked InvalidEducation            16
#;-) 503 InvalidAge     Never-worked        Doctorate             1
#;-) 573 InvalidAge     Never-worked        Doctorate            14
#;-) 575 InvalidAge      Without-pay        Doctorate            11
#;-) 589 InvalidAge        State-gov          1st-4th            13
#;-) 594 InvalidAge      Without-pay             12th             1
#;-) 609 InvalidAge      Federal-gov             12th             3
#;-) 638 InvalidAge          Private        Preschool            13
#;-) 650 InvalidAge     Self-emp-inc        Bachelors             2
#;-) 661 InvalidAge     Self-emp-inc InvalidEducation             6
#;-) 679 InvalidAge          Private              9th             4
#;-) 760 InvalidAge     Never-worked        Preschool            13
#;-) 775 InvalidAge          Private     Some-college            14
#;-) 800 InvalidAge     Self-emp-inc       Assoc-acdm            11
#;-) 834 InvalidAge        Local-gov        Preschool            12
#;-) 842 InvalidAge      Without-pay        Doctorate             2
#;-) 876 InvalidAge        Local-gov             11th             5
#;-) 888 InvalidAge          Private          HS-grad            14
#;-) 894 InvalidAge        Local-gov          1st-4th             8
#;-) 960 InvalidAge        Local-gov        Preschool            12
#;-)            marital_status        occupation   relationship               race
#;-) 9      Married-civ-spouse      Armed-Forces        Husband              Other
#;-) 21          Never-married    Prof-specialty      Unmarried              White
#;-) 68              Separated      Adm-clerical  Not-in-family Asian-Pac-Islander
#;-) 76               Divorced      Tech-support  Not-in-family              Black
#;-) 117     Married-AF-spouse Machine-op-inspct  Not-in-family Amer-Indian-Eskimo
#;-) 186             Separated   Farming-fishing      Own-child Asian-Pac-Islander
#;-) 189         Never-married   Protective-serv        Husband              Other
#;-) 230     Married-AF-spouse Handlers-cleaners Other-relative Asian-Pac-Islander
#;-) 232               Widowed   Farming-fishing  Not-in-family              White
#;-) 288               Widowed     Other-service        Husband Asian-Pac-Islander
#;-) 306              Divorced InvalidOccupation      Own-child              White
#;-) 321     Married-AF-spouse     Other-service           Wife              Other
#;-) 362    Married-civ-spouse      Adm-clerical      Unmarried              Other
#;-) 380              Divorced    Prof-specialty      Unmarried Amer-Indian-Eskimo
#;-) 406              Divorced      Adm-clerical      Unmarried              White
#;-) 407 Married-spouse-absent   Exec-managerial      Unmarried              Black
#;-) 449    Married-civ-spouse Machine-op-inspct        Husband Asian-Pac-Islander
#;-) 450             Separated  Transport-moving      Unmarried Asian-Pac-Islander
#;-) 480              Divorced    Prof-specialty           Wife              White
#;-) 503         Never-married   Protective-serv      Own-child              Other
#;-) 573    Married-civ-spouse      Adm-clerical      Own-child              Other
#;-) 575 Married-spouse-absent   Exec-managerial  Not-in-family              Black
#;-) 589 Married-spouse-absent    Prof-specialty           Wife              Other
#;-) 594               Widowed  Transport-moving        Husband Asian-Pac-Islander
#;-) 609         Never-married             Sales Other-relative Amer-Indian-Eskimo
#;-) 638             Separated   Protective-serv      Own-child              Other
#;-) 650     Married-AF-spouse      Tech-support        Husband Amer-Indian-Eskimo
#;-) 661               Widowed     Other-service      Own-child Asian-Pac-Islander
#;-) 679             Separated      Armed-Forces        Husband              Other
#;-) 760 Married-spouse-absent   Protective-serv      Own-child              Other
#;-) 775               Widowed      Craft-repair           Wife Amer-Indian-Eskimo
#;-) 800     Married-AF-spouse   Protective-serv Other-relative              White
#;-) 834    Married-civ-spouse      Armed-Forces        Husband              Other
#;-) 842 Married-spouse-absent      Adm-clerical           Wife              Black
#;-) 876             Separated   Priv-house-serv Other-relative Asian-Pac-Islander
#;-) 888    Married-civ-spouse     Other-service        Husband Asian-Pac-Islander
#;-) 894         Never-married     Other-service      Unmarried Amer-Indian-Eskimo
#;-) 960    Married-civ-spouse   Protective-serv      Own-child Amer-Indian-Eskimo
#;-)        sex capital_gain capital_loss hours_per_week             native_country
#;-) 9   Female        81715        79444             77                     Canada
#;-) 21  Female        80917        65266             50              United-States
#;-) 68    Male        92339        72412             62              United-States
#;-) 76  Female        81398        78735             79                     Mexico
#;-) 117 Female        72400        87507             91                    Ecuador
#;-) 186 Female        15747        17284              3                    Jamaica
#;-) 189 Female        65454         -999             96                    Ireland
#;-) 230   Male        70358        16571             75                       Iran
#;-) 232 Female        32326        84061             34                       Hong
#;-) 288   Male        27253        27183             77                    Hungary
#;-) 306   Male        77003        82147             24                   Cambodia
#;-) 321 Female        62901        23094             92                     Greece
#;-) 362 Female        87418        92143             27                      Italy
#;-) 380   Male        86196        46053             74                     Taiwan
#;-) 406 Female        91914        39157             57         Dominican-Republic
#;-) 407 Female        15968        66987             21                   Honduras
#;-) 449   Male        90471        34417             49                Philippines
#;-) 450 Female         -999        42299             15                   Cambodia
#;-) 480   Male        97099        63859             18                    England
#;-) 503   Male        81172         -999             86                       Peru
#;-) 573 Female        84550        41330             43                       Iran
#;-) 575   Male        34456        94416             56                    Jamaica
#;-) 589   Male        92358        31468             79                       Hong
#;-) 594 Female        44187        21023             12                     Poland
#;-) 609 Female        62574         6803             93                    Vietnam
#;-) 638   Male        49048        10309             85                   Columbia
#;-) 650 Female        91992        68676             52                    Ecuador
#;-) 661   Male         -999        82727             71                       Peru
#;-) 679   Male        52107        14519             45         Holand-Netherlands
#;-) 760 Female         -999        48157             12                Puerto-Rico
#;-) 775   Male        43231        74697             36              United-States
#;-) 800   Male         -999        23122             18                     France
#;-) 834   Male        34425        76248             43                  Nicaragua
#;-) 842   Male        11663        48569             86                    Vietnam
#;-) 876   Male          826        11760             10                   Columbia
#;-) 888 Female        44222        49219             43 Outlying-US(Guam-USVI-etc)
#;-) 894   Male        67234        18339             46                      Italy
#;-) 960   Male        95340        56560             50                    Germany
#;-)     income
#;-) 9    <=50K
#;-) 21   <=50K
#;-) 68    >50K
#;-) 76    >50K
#;-) 117  <=50K
#;-) 186  <=50K
#;-) 189  <=50K
#;-) 230  <=50K
#;-) 232  <=50K
#;-) 288   >50K
#;-) 306  <=50K
#;-) 321  <=50K
#;-) 362  <=50K
#;-) 380  <=50K
#;-) 406  <=50K
#;-) 407  <=50K
#;-) 449  <=50K
#;-) 450  <=50K
#;-) 480  <=50K
#;-) 503  <=50K
#;-) 573   >50K
#;-) 575   >50K
#;-) 589  <=50K
#;-) 594  <=50K
#;-) 609  <=50K
#;-) 638  <=50K
#;-) 650  <=50K
#;-) 661  <=50K
#;-) 679  <=50K
#;-) 760  <=50K
#;-) 775  <=50K
#;-) 800  <=50K
#;-) 834   >50K
#;-) 842   >50K
#;-) 876  <=50K
#;-) 888  <=50K
#;-) 894  <=50K
#;-) 960  <=50K

median_age <- median(sample_dirty_dataset$age[sample_dirty_dataset$age != "InvalidAge"], na.rm = TRUE)

sample_dirty_dataset$age[sample_dirty_dataset$age == "InvalidAge"] <- median_age #imputing mean age values in InvalidAge place

sample_dirty_dataset$age <- as.integer(sample_dirty_dataset$age)



### HANDLING INVALID EDUCATION with bar plot and replacing it with most common education
invalid_education_counts <- table(sample_dirty_dataset$education == "InvalidEducation")

barplot(invalid_education_counts, 
        main = "Occurrences of InvalidEducation", 
        xlab = "InvalidEducation",
        ylab = "Occurrences",
        col = "blue",
        ylim = c(0, max(invalid_education_counts)))


education_counts <- table(sample_dirty_dataset$education)

education_counts
#;-) 
#;-)             10th             11th             12th          1st-4th 
#;-)               42               50               46               39 
#;-)          5th-6th          7th-8th              9th       Assoc-acdm 
#;-)               35               48               49               35 
#;-)        Assoc-voc        Bachelors        Doctorate          HS-grad 
#;-)               46               39               45               49 
#;-) InvalidEducation          Masters        Preschool      Prof-school 
#;-)               36               57               42               34 
#;-)     Some-college 
#;-)               47

sample_dirty_dataset$education[sample_dirty_dataset$education == "InvalidEducation"] <-
"11th"



### CALCULATING MEDIAN CAPITAL GAIN
median_gain_capital <- median(sample_dirty_dataset$capital_gain[sample_dirty_dataset$capital_gain != -999], na.rm = TRUE)

### REPLACING MEDIAN CAPITAL GAIN
sample_dirty_dataset$capital_gain[sample_dirty_dataset$capital_gain == -999] <-
  
median_gain_capital

### CALCULATING MEDIAN CAPITAL LOSS
median_loss_capital <- median(sample_dirty_dataset$capital_loss[sample_dirty_dataset$capital_loss != -999], na.rm = TRUE)

### REPLACING -999 CAPITAL LOSS with median capital loss
sample_dirty_dataset$capital_loss[sample_dirty_dataset$capital_loss == -999] <-
  
median_loss_capital

### HANDLING INVALID OCCUPATION

occupation_levels <- unique(sample_dirty_dataset$occupation)
#print(occupation_levels) #InvalidOccupation

occupation_count <- sum(sample_dirty_dataset$occupation == "InvalidOccupation", na.rm = TRUE)

#occupation_count #43

occupation_counts <- table(sample_dirty_dataset$occupation)

occupation_counts #most common Adm-clerical 66
#;-) 
#;-)      Adm-clerical      Armed-Forces      Craft-repair   Exec-managerial 
#;-)                66                47                54                54 
#;-)   Farming-fishing Handlers-cleaners InvalidOccupation Machine-op-inspct 
#;-)                36                43                43                46 
#;-)     Other-service   Priv-house-serv    Prof-specialty   Protective-serv 
#;-)                54                53                62                53 
#;-)             Sales      Tech-support  Transport-moving 
#;-)                44                40                44

### REPLACING INVALID OCCUPATION WITH MOST COMMON OCCUPATION
sample_dirty_dataset$occupation[sample_dirty_dataset$occupation == "InvalidOccupation"] <-
"Adm-clerical"

occupation_count <- sum(sample_dirty_dataset$occupation == "InvalidOccupation", na.rm = TRUE)

occupation_count #0
#;-) [1] 0

sample_dirty_dataset$capital_gain <- as.integer(sample_dirty_dataset$capital_gain)


### ZSCORE OUTLIERS
# Calculate z-scores
zscore <- abs(scale(sample_dirty_dataset$capital_gain))

# Create a data frame for plotting
zscore_df <- data.frame(Data_Point_Index = 1:length(zscore),
                        Z_Score = zscore)

# Plot z-scores as a scatter plot
plot(zscore_df$Data_Point_Index, zscore_df$Z_Score, 
     col = ifelse(zscore_df$Z_Score > 2, "darkgreen", "blue"), 
     pch = 19,
     main = "Z-scores of Capital gain", 
     xlab = "Data Point Index", ylab = "Z-score", 
     ylim = c(0, max(zscore) + 1))

# Add horizontal line for threshold
abline(h = 2, col = "red", lty = 2)

# Add legend
legend("topright", legend = c("Z-score", "Threshold (2)", "Exceeding Threshold"), 
       col = c("blue", "red", "darkgreen"), lty = c(NA, 2, NA), 
       pch = c(19, NA, 19))


### BOX PLOT CAPITAL LOSS AND AGE


boxplot(sample_dirty_dataset$capital_loss)
boxplot(sample_dirty_dataset$capital_loss)$out

#;-) numeric(0)

boxplot(sample_dirty_dataset$age)
boxplot(sample_dirty_dataset$age)$out

#;-) numeric(0)

#NO OUTLIERS

### OUTLIERS hours_per_week

par(mfrow=c(2,2))
plot(covMcd(sample_dirty_dataset$hours_per_week))



### SUMMARY
summary(sample_dirty_dataset)
#;-)       age         workclass          education         education_num   
#;-)  Min.   :18.00   Length:739         Length:739         Min.   : 1.000  
#;-)  1st Qu.:37.00   Class :character   Class :character   1st Qu.: 5.000  
#;-)  Median :53.00   Mode  :character   Mode  :character   Median : 9.000  
#;-)  Mean   :54.35                                         Mean   : 8.829  
#;-)  3rd Qu.:73.00                                         3rd Qu.:13.000  
#;-)  Max.   :90.00                                         Max.   :16.000  
#;-)  marital_status      occupation        relationship           race          
#;-)  Length:739         Length:739         Length:739         Length:739        
#;-)  Class :character   Class :character   Class :character   Class :character  
#;-)  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
#;-)                                                                             
#;-)                                                                             
#;-)                                                                             
#;-)      sex             capital_gain    capital_loss   hours_per_week 
#;-)  Length:739         Min.   :  200   Min.   :   70   Min.   : 1.00  
#;-)  Class :character   1st Qu.:26138   1st Qu.:26396   1st Qu.:24.00  
#;-)  Mode  :character   Median :48885   Median :48779   Median :49.00  
#;-)                     Mean   :49756   Mean   :50396   Mean   :50.27  
#;-)                     3rd Qu.:74198   3rd Qu.:75590   3rd Qu.:77.00  
#;-)                     Max.   :99692   Max.   :99727   Max.   :99.00  
#;-)  native_country        income         
#;-)  Length:739         Length:739        
#;-)  Class :character   Class :character  
#;-)  Mode  :character   Mode  :character  
#;-)                                       
#;-)                                       
#;-) 

head(sample_dirty_dataset)
#;-)   age        workclass    education education_num        marital_status
#;-) 1  26      Federal-gov   Assoc-acdm             2             Separated
#;-) 2  72          Private      HS-grad            16    Married-civ-spouse
#;-) 3  89      Federal-gov      HS-grad            14 Married-spouse-absent
#;-) 5  56      Without-pay      5th-6th             5             Separated
#;-) 6  32 Self-emp-not-inc   Assoc-acdm             4     Married-AF-spouse
#;-) 7  32        State-gov Some-college            16 Married-spouse-absent
#;-)          occupation   relationship               race    sex capital_gain
#;-) 1      Craft-repair  Not-in-family              Other Female        95729
#;-) 2 Machine-op-inspct      Unmarried Asian-Pac-Islander Female        16548
#;-) 3      Armed-Forces  Not-in-family              Black   Male        26865
#;-) 5   Priv-house-serv Other-relative              Other   Male        97828
#;-) 6      Adm-clerical        Husband              Black Female        76074
#;-) 7      Adm-clerical        Husband              Other   Male        16495
#;-)   capital_loss hours_per_week native_country income
#;-) 1        78233             71           Laos  <=50K
#;-) 2        91089             81          Italy  <=50K
#;-) 3         5355             51        Ecuador   >50K
#;-) 5        17804             47          Italy  <=50K
#;-) 6        28165             31          China  <=50K
#;-) 7        63343             71           Iran   >50K

#sample_dirty_dataset


### REPORTS
diagnose_web_report(sample_dirty_dataset)
#;-) processing file: diagnosis_temp.Rmd
#;-) output file: diagnosis_temp.knit.md
#;-) /Users/kacperpietka/Desktop/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc +RTS -K512m -RTS diagnosis_temp.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /var/folders/g3/ldv1ypn57td1phswkr2h7yc80000gn/T//RtmpKRaIct/Diagnosis_Report.html --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --template /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --css /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/dlookr/resources/dlookr-bootstrap.css --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/g3/ldv1ypn57td1phswkr2h7yc80000gn/T//RtmpKRaIct/rmarkdown-str66c17ed11537.html --variable code_folding=show --variable code_menu=1 --include-in-header header_temp.html --include-after-body /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/dlookr/resources/footer.html
#;-) 
#;-) Output created: /var/folders/g3/ldv1ypn57td1phswkr2h7yc80000gn/T//RtmpKRaIct/Diagnosis_Report.html
eda_web_report(sample_dirty_dataset)
#;-) processing file: eda_temp.Rmd
#;-) Error in parse_block(g[-1], g[1], params.src, markdown_mode): Duplicate chunk label 'unnamed-chunk-1', which has been used for the chunk:
#;-) cat(sprintf("*Local `.Rprofile` detected at `%s`*", normalizePath(".Rprofile")))
transformation_paged_report(sample_dirty_dataset)
#;-) processing file: transformation_paged_temp.Rmd
#;-) Error in parse_block(g[-1], g[1], params.src, markdown_mode): Duplicate chunk label 'unnamed-chunk-1', which has been used for the chunk:
#;-) cat(sprintf("*Local `.Rprofile` detected at `%s`*", normalizePath(".Rprofile")))
Standard output and standard error
✖ Install the styler package in order to use `style = TRUE`.
Session info
sessionInfo()
#;-) R version 4.3.3 (2024-02-29)
#;-) Platform: aarch64-apple-darwin20 (64-bit)
#;-) Running under: macOS Sonoma 14.4
#;-) 
#;-) Matrix products: default
#;-) BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
#;-) LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
#;-) 
#;-) locale:
#;-) [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#;-) 
#;-) time zone: Europe/Warsaw
#;-) tzcode source: internal
#;-) 
#;-) attached base packages:
#;-) [1] stats     graphics  grDevices utils     datasets  methods   base     
#;-) 
#;-) other attached packages:
#;-)  [1] htmltools_0.5.7   reactable_0.4.4   kableExtra_1.4.0  rrcov_1.7-5      
#;-)  [5] robustbase_0.99-2 dlookr_0.6.3      lubridate_1.9.3   forcats_1.0.0    
#;-)  [9] stringr_1.5.1     dplyr_1.1.4       purrr_1.0.2       readr_2.1.5      
#;-) [13] tidyr_1.3.1       tibble_3.2.1      ggplot2_3.5.0     tidyverse_2.0.0  
#;-) 
#;-) loaded via a namespace (and not attached):
#;-)  [1] tidyselect_1.2.0        viridisLite_0.4.2       farver_2.1.1           
#;-)  [4] fastmap_1.1.1           pagedown_0.20           fontquiver_0.2.1       
#;-)  [7] promises_1.2.1          reprex_2.1.0            digest_0.6.34          
#;-) [10] timechange_0.3.0        mime_0.12               lifecycle_1.0.4        
#;-) [13] ellipsis_0.3.2          gfonts_0.2.0            magrittr_2.0.3         
#;-) [16] compiler_4.3.3          rlang_1.1.3             sass_0.4.8             
#;-) [19] tools_4.3.3             utf8_1.2.4              yaml_2.3.8             
#;-) [22] knitr_1.45              labeling_0.4.3          htmlwidgets_1.6.4      
#;-) [25] curl_5.2.1              xml2_1.3.6              showtextdb_3.0         
#;-) [28] httpcode_0.3.0          withr_3.0.0             grid_4.3.3             
#;-) [31] pcaPP_2.0-4             stats4_4.3.3            fansi_1.0.6            
#;-) [34] sysfonts_0.8.9          gdtools_0.3.7           xtable_1.8-4           
#;-) [37] colorspace_2.1-0        extrafontdb_1.0         scales_1.3.0           
#;-) [40] crul_1.4.0              cli_3.6.2               mvtnorm_1.2-4          
#;-) [43] rmarkdown_2.26          crayon_1.5.2            generics_0.1.3         
#;-) [46] rstudioapi_0.15.0       tzdb_0.4.0              cachem_1.0.8           
#;-) [49] base64enc_0.1-3         vctrs_0.6.5             jsonlite_1.8.8         
#;-) [52] fontBitstreamVera_0.1.1 bookdown_0.38           hms_1.1.3              
#;-) [55] systemfonts_1.0.6       fontawesome_0.5.2       jquerylib_0.1.4        
#;-) [58] glue_1.7.0              reactR_0.5.0            DEoptimR_1.1-3         
#;-) [61] stringi_1.8.3           gtable_0.3.4            later_1.3.2            
#;-) [64] extrafont_0.19          munsell_0.5.0           pillar_1.9.0           
#;-) [67] showtext_0.9-7          R6_2.5.1                evaluate_0.23          
#;-) [70] shiny_1.8.1             lattice_0.22-5          highr_0.10             
#;-) [73] fontLiberation_0.1.0    httpuv_1.6.15           bslib_0.6.1            
#;-) [76] hrbrthemes_0.8.7        Rcpp_1.0.12             svglite_2.1.3          
#;-) [79] gridExtra_2.3           Rttf2pt1_1.3.12         xfun_0.42              
#;-) [82] fs_1.6.3                pkgconfig_2.0.3