credit_data = read.csv(("/Users/tbs/Downloads/Data Sets 'R'/credit_data.csv"))

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(purrr)

Random sampling of credit_data dataset

num <-sample(5:10,1)
columns <- c("Income", "Occupation", "Loan.Amount", "Credit.Score", "City", "LTV.Ratio", "Profile.Score")
subsample_list <- list()
for (i in 1:num) {
  
  # Determine sample size (approximately 50% of the data)
  s_size <- round(0.5 * nrow(credit_data))
  
  # Randomly select rows with replacement
  s_index <- sample(1:nrow(credit_data), size = s_size, replace = TRUE)
  
  # Create the subsample data frame
  sub_sample <- credit_data[s_index, columns]
  
  # Store the subsample in the list
  subsample_list[[i]] <- sub_sample
}

Displaying the dimensions of each subsample

sapply(subsample_list, dim)
##        [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]
## [1,] 139928 139928 139928 139928 139928 139928 139928 139928 139928 139928
## [2,]      7      7      7      7      7      7      7      7      7      7

Summaries of the sample data

summary_table <- lapply(subsample_list, function(subsample){
  summary_df <-summary(subsample)
  knitr::kable(summary_df, caption = "summary statistics")
}) 
for (i in 1: num){
  cat("### Subsample", i, "summary statisics \n")
  print(summary_table[[i]])
}
## ### Subsample 1 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 71994 |1st Qu.:446.0 |Class :character |1st Qu.:58.11 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111163 |Median :584.0 |Mode  :character |Median :72.06 |Median : 89.00 |
## |   |Mean   : 76364 |NA               |Mean   :105770 |Mean   :582.9 |NA               |Mean   :71.60 |Mean   : 77.31 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:722.0 |NA               |3rd Qu.:86.25 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 2 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72667 |1st Qu.:446.0 |Class :character |1st Qu.:58.16 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111544 |Median :584.0 |Mode  :character |Median :72.10 |Median : 89.00 |
## |   |Mean   : 76297 |NA               |Mean   :105933 |Mean   :582.4 |NA               |Mean   :71.68 |Mean   : 77.32 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:720.0 |NA               |3rd Qu.:86.25 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 3 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5319 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72375 |1st Qu.:446.0 |Class :character |1st Qu.:58.08 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111255 |Median :584.0 |Mode  :character |Median :72.12 |Median : 89.00 |
## |   |Mean   : 76478 |NA               |Mean   :105782 |Mean   :583.2 |NA               |Mean   :71.64 |Mean   : 77.39 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.24 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 4 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 71983 |1st Qu.:446.0 |Class :character |1st Qu.:58.08 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111322 |Median :585.0 |Mode  :character |Median :72.16 |Median : 89.00 |
## |   |Mean   : 76468 |NA               |Mean   :105788 |Mean   :583.1 |NA               |Mean   :71.64 |Mean   : 77.34 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.20 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 5 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5514 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72266 |1st Qu.:447.0 |Class :character |1st Qu.:58.02 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111157 |Median :584.0 |Mode  :character |Median :72.08 |Median : 89.00 |
## |   |Mean   : 76449 |NA               |Mean   :105771 |Mean   :583.1 |NA               |Mean   :71.60 |Mean   : 77.41 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.22 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 6 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 43000 |Class :character |1st Qu.: 72081 |1st Qu.:446.0 |Class :character |1st Qu.:57.98 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111206 |Median :585.0 |Mode  :character |Median :72.07 |Median : 89.00 |
## |   |Mean   : 76546 |NA               |Mean   :105748 |Mean   :583.3 |NA               |Mean   :71.58 |Mean   : 77.44 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.10 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 7 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72149 |1st Qu.:447.0 |Class :character |1st Qu.:58.11 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :110764 |Median :585.0 |Mode  :character |Median :72.14 |Median : 89.00 |
## |   |Mean   : 76499 |NA               |Mean   :105592 |Mean   :583.5 |NA               |Mean   :71.67 |Mean   : 77.44 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.26 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 8 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72266 |1st Qu.:445.0 |Class :character |1st Qu.:58.12 |1st Qu.: 61.00 |
## |   |Median : 67000 |Mode  :character |Median :111214 |Median :584.0 |Mode  :character |Median :72.20 |Median : 89.00 |
## |   |Mean   : 76374 |NA               |Mean   :105767 |Mean   :582.4 |NA               |Mean   :71.68 |Mean   : 77.24 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:722.0 |NA               |3rd Qu.:86.32 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 9 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5294 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72497 |1st Qu.:446.0 |Class :character |1st Qu.:58.09 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111142 |Median :583.0 |Mode  :character |Median :72.22 |Median : 89.00 |
## |   |Mean   : 76686 |NA               |Mean   :105822 |Mean   :582.8 |NA               |Mean   :71.66 |Mean   : 77.32 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:723.0 |NA               |3rd Qu.:86.24 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |
## ### Subsample 10 summary statisics 
## 
## 
## Table: summary statistics
## 
## |   |    Income     | Occupation      | Loan.Amount   | Credit.Score |    City         |  LTV.Ratio   |Profile.Score  |
## |:--|:--------------|:----------------|:--------------|:-------------|:----------------|:-------------|:--------------|
## |   |Min.   :  9000 |Length:139928    |Min.   :  5319 |Min.   :300.0 |Length:139928    |Min.   :40.00 |Min.   :  0.00 |
## |   |1st Qu.: 42000 |Class :character |1st Qu.: 72626 |1st Qu.:447.0 |Class :character |1st Qu.:58.10 |1st Qu.: 61.00 |
## |   |Median : 68000 |Mode  :character |Median :111712 |Median :584.0 |Mode  :character |Median :72.10 |Median : 89.00 |
## |   |Mean   : 76593 |NA               |Mean   :106088 |Mean   :583.4 |NA               |Mean   :71.63 |Mean   : 77.35 |
## |   |3rd Qu.:104000 |NA               |3rd Qu.:150000 |3rd Qu.:724.0 |NA               |3rd Qu.:86.26 |3rd Qu.: 98.00 |
## |   |Max.   :209000 |NA               |Max.   :150000 |Max.   :850.0 |NA               |Max.   :95.00 |Max.   :100.00 |

Scrutinizing subsamples

# summary statistics for each subsamples
summary_stats <-lapply(subsample_list, summary)
# plot histogram
histograms <- lapply(subsample_list, function(subsample) {
  ggplot(subsample, aes(x = Income)) +
    geom_histogram(binwidth = 1, fill = 'blue', color = 'black') +
    labs(title = "Histogram for Income", x = 'Value', y = 'Frequency')
})
# display histograms and summary
for (i in 1:num) {
  cat("Subsample", i, "summary statistics:\n")
  print(summary_stats[[i]])
  print(histograms[[i]])
}
## Subsample 1 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 71994   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111163   Median :584.0  
##  Mean   : 76364                      Mean   :105770   Mean   :582.9  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:722.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.11   1st Qu.: 61.00  
##  Mode  :character   Median :72.06   Median : 89.00  
##                     Mean   :71.60   Mean   : 77.31  
##                     3rd Qu.:86.25   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 2 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72667   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111544   Median :584.0  
##  Mean   : 76297                      Mean   :105933   Mean   :582.4  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:720.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.16   1st Qu.: 61.00  
##  Mode  :character   Median :72.10   Median : 89.00  
##                     Mean   :71.68   Mean   : 77.32  
##                     3rd Qu.:86.25   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 3 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5319   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72375   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111255   Median :584.0  
##  Mean   : 76478                      Mean   :105782   Mean   :583.2  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.08   1st Qu.: 61.00  
##  Mode  :character   Median :72.12   Median : 89.00  
##                     Mean   :71.64   Mean   : 77.39  
##                     3rd Qu.:86.24   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 4 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 71983   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111322   Median :585.0  
##  Mean   : 76468                      Mean   :105788   Mean   :583.1  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.08   1st Qu.: 61.00  
##  Mode  :character   Median :72.16   Median : 89.00  
##                     Mean   :71.64   Mean   : 77.34  
##                     3rd Qu.:86.20   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 5 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5514   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72266   1st Qu.:447.0  
##  Median : 68000   Mode  :character   Median :111157   Median :584.0  
##  Mean   : 76449                      Mean   :105771   Mean   :583.1  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.02   1st Qu.: 61.00  
##  Mode  :character   Median :72.08   Median : 89.00  
##                     Mean   :71.60   Mean   : 77.41  
##                     3rd Qu.:86.22   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 6 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 43000   Class :character   1st Qu.: 72081   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111206   Median :585.0  
##  Mean   : 76546                      Mean   :105748   Mean   :583.3  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:57.98   1st Qu.: 61.00  
##  Mode  :character   Median :72.07   Median : 89.00  
##                     Mean   :71.58   Mean   : 77.44  
##                     3rd Qu.:86.10   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 7 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72149   1st Qu.:447.0  
##  Median : 68000   Mode  :character   Median :110764   Median :585.0  
##  Mean   : 76499                      Mean   :105592   Mean   :583.5  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.11   1st Qu.: 61.00  
##  Mode  :character   Median :72.14   Median : 89.00  
##                     Mean   :71.67   Mean   : 77.44  
##                     3rd Qu.:86.26   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 8 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72266   1st Qu.:445.0  
##  Median : 67000   Mode  :character   Median :111214   Median :584.0  
##  Mean   : 76374                      Mean   :105767   Mean   :582.4  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:722.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.12   1st Qu.: 61.00  
##  Mode  :character   Median :72.20   Median : 89.00  
##                     Mean   :71.68   Mean   : 77.24  
##                     3rd Qu.:86.32   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 9 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5294   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72497   1st Qu.:446.0  
##  Median : 68000   Mode  :character   Median :111142   Median :583.0  
##  Mean   : 76686                      Mean   :105822   Mean   :582.8  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:723.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.09   1st Qu.: 61.00  
##  Mode  :character   Median :72.22   Median : 89.00  
##                     Mean   :71.66   Mean   : 77.32  
##                     3rd Qu.:86.24   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

## Subsample 10 summary statistics:
##      Income        Occupation         Loan.Amount      Credit.Score  
##  Min.   :  9000   Length:139928      Min.   :  5319   Min.   :300.0  
##  1st Qu.: 42000   Class :character   1st Qu.: 72626   1st Qu.:447.0  
##  Median : 68000   Mode  :character   Median :111712   Median :584.0  
##  Mean   : 76593                      Mean   :106088   Mean   :583.4  
##  3rd Qu.:104000                      3rd Qu.:150000   3rd Qu.:724.0  
##  Max.   :209000                      Max.   :150000   Max.   :850.0  
##      City             LTV.Ratio     Profile.Score   
##  Length:139928      Min.   :40.00   Min.   :  0.00  
##  Class :character   1st Qu.:58.10   1st Qu.: 61.00  
##  Mode  :character   Median :72.10   Median : 89.00  
##                     Mean   :71.63   Mean   : 77.35  
##                     3rd Qu.:86.26   3rd Qu.: 98.00  
##                     Max.   :95.00   Max.   :100.00

Summary:- After randomly sampling data, I noticed that the existing customers who have taken out loans consistently exhibit patterns in their income across all the samples, with only minor variations. This suggests a level of stability in their order frequency.

Anomalies and consistency

means <- lapply(subsample_list, function(subsample) {
  mean(subsample$Income)
})
print(means)
## [[1]]
## [1] 76364.32
## 
## [[2]]
## [1] 76296.7
## 
## [[3]]
## [1] 76478.46
## 
## [[4]]
## [1] 76467.75
## 
## [[5]]
## [1] 76449.1
## 
## [[6]]
## [1] 76546.47
## 
## [[7]]
## [1] 76498.89
## 
## [[8]]
## [1] 76374.28
## 
## [[9]]
## [1] 76685.63
## 
## [[10]]
## [1] 76593.13
sds <- lapply(subsample_list, function(subsample) {
  sd(subsample$Income)
})
print(sds)
## [[1]]
## [1] 42760.46
## 
## [[2]]
## [1] 42769.19
## 
## [[3]]
## [1] 42821.72
## 
## [[4]]
## [1] 42894.51
## 
## [[5]]
## [1] 42833.76
## 
## [[6]]
## [1] 42840.66
## 
## [[7]]
## [1] 42959.06
## 
## [[8]]
## [1] 42874.43
## 
## [[9]]
## [1] 42968.08
## 
## [[10]]
## [1] 42900.76
for (i in 1:num) {
  cat("Subsample", i, "Mean of Income:", means[[i]], "\n")
  cat("Subsample", i, "SD of Income:", sds[[i]], "\n")
}
## Subsample 1 Mean of Income: 76364.32 
## Subsample 1 SD of Income: 42760.46 
## Subsample 2 Mean of Income: 76296.7 
## Subsample 2 SD of Income: 42769.19 
## Subsample 3 Mean of Income: 76478.46 
## Subsample 3 SD of Income: 42821.72 
## Subsample 4 Mean of Income: 76467.75 
## Subsample 4 SD of Income: 42894.51 
## Subsample 5 Mean of Income: 76449.1 
## Subsample 5 SD of Income: 42833.76 
## Subsample 6 Mean of Income: 76546.47 
## Subsample 6 SD of Income: 42840.66 
## Subsample 7 Mean of Income: 76498.89 
## Subsample 7 SD of Income: 42959.06 
## Subsample 8 Mean of Income: 76374.28 
## Subsample 8 SD of Income: 42874.43 
## Subsample 9 Mean of Income: 76685.63 
## Subsample 9 SD of Income: 42968.08 
## Subsample 10 Mean of Income: 76593.13 
## Subsample 10 SD of Income: 42900.76

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.