# ==============================
# INPUT PACKAGE
# ==============================
library(readxl)
library(ggplot2)
# ==============================
# INPUT DATA CKD
# ==============================
data_ckd <- read_excel(file.choose())
# Melihat data awal
head(data_ckd)
## # A tibble: 6 × 19
## `Age of the patient` `Blood pressure (mm/Hg)` `Red blood cells in urine`
## <dbl> <dbl> <chr>
## 1 54 167 normal
## 2 42 127 normal
## 3 38 148 abnormal
## 4 67 174 normal
## 5 67 100 normal
## 6 42 138 abnormal
## # ℹ 16 more variables: `Bacteria in urine` <chr>, `Blood urea (mg/dl)` <dbl>,
## # `Serum creatinine (mg/dl)` <dbl>, `Hemoglobin level (gms)` <dbl>,
## # `Hypertension (yes/no)` <chr>, `Diabetes mellitus (yes/no)` <chr>,
## # `Coronary artery disease (yes/no)` <chr>, `Anemia (yes/no)` <chr>,
## # `Urine protein-to-creatinine ratio` <dbl>, `Urine output (ml/day)` <dbl>,
## # `Cholesterol level` <dbl>,
## # `Family history of chronic kidney disease` <chr>, `Smoking status` <chr>, …
# Melihat struktur data
str(data_ckd)
## tibble [50 × 19] (S3: tbl_df/tbl/data.frame)
## $ Age of the patient : num [1:50] 54 42 38 67 67 42 84 49 65 25 ...
## $ Blood pressure (mm/Hg) : num [1:50] 167 127 148 174 100 138 104 113 126 174 ...
## $ Red blood cells in urine : chr [1:50] "normal" "normal" "abnormal" "normal" ...
## $ Bacteria in urine : chr [1:50] "not present" "present" "not present" "not present" ...
## $ Blood urea (mg/dl) : num [1:50] 169.1 183.2 193.1 197.2 27.3 ...
## $ Serum creatinine (mg/dl) : num [1:50] 7.55 13.37 9.49 3.01 8.73 ...
## $ Hemoglobin level (gms) : num [1:50] 11.8 8.2 10.1 16.1 7.7 8.8 7.2 12.6 7.5 15.6 ...
## $ Hypertension (yes/no) : chr [1:50] "yes" "no" "no" "no" ...
## $ Diabetes mellitus (yes/no) : chr [1:50] "yes" "yes" "no" "no" ...
## $ Coronary artery disease (yes/no) : chr [1:50] "no" "no" "yes" "no" ...
## $ Anemia (yes/no) : chr [1:50] "no" "yes" "no" "yes" ...
## $ Urine protein-to-creatinine ratio : num [1:50] 2.51 4.27 1.56 1.23 2.61 2.42 1.67 0.41 2.8 0.46 ...
## $ Urine output (ml/day) : num [1:50] 1397 1632 889 893 1212 ...
## $ Cholesterol level : num [1:50] 152 242 103 149 182 260 134 229 276 206 ...
## $ Family history of chronic kidney disease: chr [1:50] "no" "yes" "no" "no" ...
## $ Smoking status : chr [1:50] "yes" "no" "no" "yes" ...
## $ Body Mass Index (BMI) : num [1:50] 25.3 20.6 38.4 17.6 37.2 23.5 23 30.6 16.8 28.5 ...
## $ Physical activity level : chr [1:50] "low" "moderate" "high" "high" ...
## $ CKD Status : chr [1:50] "Yes" "Yes" "No" "Yes" ...
# ==============================
# VISUALISASI STATUS CKD
# ==============================
ggplot(data_ckd, aes(x = `CKD Status`)) +
geom_bar(fill = "skyblue") +
labs(
title = "Distribusi Status CKD",
x = "Status CKD",
y = "Jumlah Pasien"
) +
theme_minimal()

# ==============================
# DISTRIBUSI USIA PASIEN CKD
# ==============================
ggplot(data_ckd, aes(x = `Age of the patient`)) +
geom_histogram(
fill = "lightgreen",
color = "black",
bins = 10
) +
labs(
title = "Distribusi Usia Pasien CKD",
x = "Usia (Tahun)",
y = "Frekuensi"
) +
theme_minimal()

# ==============================
# USIA BERDASARKAN STATUS CKD
# ==============================
ggplot(data_ckd, aes(
x = `CKD Status`,
y = `Age of the patient`,
fill = `CKD Status`
)) +
geom_boxplot() +
labs(
title = "Distribusi Usia Berdasarkan Status CKD",
x = "Status CKD",
y = "Usia Pasien"
) +
theme_minimal()

# ==============================
# SERUM KREATININ BERDASARKAN STATUS CKD
# ==============================
ggplot(data_ckd, aes(
x = `CKD Status`,
y = `Serum creatinine (mg/dl)`,
fill = `CKD Status`
)) +
geom_boxplot() +
labs(
title = "Serum Kreatinin Berdasarkan Status CKD",
x = "Status CKD",
y = "Serum Kreatinin (mg/dl)"
) +
theme_minimal()

# ==============================
# HUBUNGAN HIPERTENSI DENGAN STATUS CKD
# ==============================
ggplot(data_ckd, aes(
x = `Hypertension (yes/no)`,
fill = `CKD Status`
)) +
geom_bar(position = "dodge") +
labs(
title = "Hubungan Hipertensi dengan CKD",
x = "Hipertensi",
y = "Jumlah Pasien"
) +
theme_minimal()

# ANALISIS STATISTIK DESKRIPTIF CKD
# Memanggil package
library(readxl)
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
# Input data CKD
data_ckd <- read_excel(file.choose())
# Melihat data awal
head(data_ckd)
## # A tibble: 6 × 19
## `Age of the patient` `Blood pressure (mm/Hg)` `Red blood cells in urine`
## <dbl> <dbl> <chr>
## 1 54 167 normal
## 2 42 127 normal
## 3 38 148 abnormal
## 4 67 174 normal
## 5 67 100 normal
## 6 42 138 abnormal
## # ℹ 16 more variables: `Bacteria in urine` <chr>, `Blood urea (mg/dl)` <dbl>,
## # `Serum creatinine (mg/dl)` <dbl>, `Hemoglobin level (gms)` <dbl>,
## # `Hypertension (yes/no)` <chr>, `Diabetes mellitus (yes/no)` <chr>,
## # `Coronary artery disease (yes/no)` <chr>, `Anemia (yes/no)` <chr>,
## # `Urine protein-to-creatinine ratio` <dbl>, `Urine output (ml/day)` <dbl>,
## # `Cholesterol level` <dbl>,
## # `Family history of chronic kidney disease` <chr>, `Smoking status` <chr>, …
# Melihat struktur data
str(data_ckd)
## tibble [50 × 19] (S3: tbl_df/tbl/data.frame)
## $ Age of the patient : num [1:50] 54 42 38 67 67 42 84 49 65 25 ...
## $ Blood pressure (mm/Hg) : num [1:50] 167 127 148 174 100 138 104 113 126 174 ...
## $ Red blood cells in urine : chr [1:50] "normal" "normal" "abnormal" "normal" ...
## $ Bacteria in urine : chr [1:50] "not present" "present" "not present" "not present" ...
## $ Blood urea (mg/dl) : num [1:50] 169.1 183.2 193.1 197.2 27.3 ...
## $ Serum creatinine (mg/dl) : num [1:50] 7.55 13.37 9.49 3.01 8.73 ...
## $ Hemoglobin level (gms) : num [1:50] 11.8 8.2 10.1 16.1 7.7 8.8 7.2 12.6 7.5 15.6 ...
## $ Hypertension (yes/no) : chr [1:50] "yes" "no" "no" "no" ...
## $ Diabetes mellitus (yes/no) : chr [1:50] "yes" "yes" "no" "no" ...
## $ Coronary artery disease (yes/no) : chr [1:50] "no" "no" "yes" "no" ...
## $ Anemia (yes/no) : chr [1:50] "no" "yes" "no" "yes" ...
## $ Urine protein-to-creatinine ratio : num [1:50] 2.51 4.27 1.56 1.23 2.61 2.42 1.67 0.41 2.8 0.46 ...
## $ Urine output (ml/day) : num [1:50] 1397 1632 889 893 1212 ...
## $ Cholesterol level : num [1:50] 152 242 103 149 182 260 134 229 276 206 ...
## $ Family history of chronic kidney disease: chr [1:50] "no" "yes" "no" "no" ...
## $ Smoking status : chr [1:50] "yes" "no" "no" "yes" ...
## $ Body Mass Index (BMI) : num [1:50] 25.3 20.6 38.4 17.6 37.2 23.5 23 30.6 16.8 28.5 ...
## $ Physical activity level : chr [1:50] "low" "moderate" "high" "high" ...
## $ CKD Status : chr [1:50] "Yes" "Yes" "No" "Yes" ...
# Melihat ukuran data
dim(data_ckd)
## [1] 50 19
# ==============================
# STATISTIK DESKRIPTIF
# ==============================
# Ringkasan statistik seluruh data
summary(data_ckd)
## Age of the patient Blood pressure (mm/Hg) Red blood cells in urine
## Min. :25.00 Min. : 80.0 Length :50
## 1st Qu.:38.50 1st Qu.:113.0 N.unique : 2
## Median :54.50 Median :127.5 N.blank : 0
## Mean :56.90 Mean :131.9 Min.nchar: 6
## 3rd Qu.:71.75 3rd Qu.:156.0 Max.nchar: 8
## Max. :90.00 Max. :179.0
## Bacteria in urine Blood urea (mg/dl) Serum creatinine (mg/dl)
## Length :50 Min. : 8.685 Min. : 0.760
## N.unique : 2 1st Qu.: 46.188 1st Qu.: 4.940
## N.blank : 0 Median : 97.618 Median : 8.170
## Min.nchar: 7 Mean :101.266 Mean : 7.613
## Max.nchar:11 3rd Qu.:147.020 3rd Qu.:10.352
## Max. :198.726 Max. :14.580
## Hemoglobin level (gms) Hypertension (yes/no) Diabetes mellitus (yes/no)
## Min. : 6.000 Length :50 Length :50
## 1st Qu.: 9.525 N.unique : 2 N.unique : 2
## Median :11.850 N.blank : 0 N.blank : 0
## Mean :12.092 Min.nchar: 2 Min.nchar: 2
## 3rd Qu.:15.225 Max.nchar: 3 Max.nchar: 3
## Max. :17.500
## Coronary artery disease (yes/no) Anemia (yes/no)
## Length :50 Length :50
## N.unique : 2 N.unique : 2
## N.blank : 0 N.blank : 0
## Min.nchar: 2 Min.nchar: 2
## Max.nchar: 3 Max.nchar: 3
##
## Urine protein-to-creatinine ratio Urine output (ml/day) Cholesterol level
## Min. :0.240 Min. : 308.0 Min. :100.0
## 1st Qu.:1.260 1st Qu.: 931.5 1st Qu.:135.2
## Median :2.380 Median :1740.5 Median :214.0
## Mean :2.300 Mean :1739.5 Mean :199.5
## 3rd Qu.:3.277 3rd Qu.:2416.2 3rd Qu.:257.0
## Max. :4.490 Max. :2933.0 Max. :298.0
## Family history of chronic kidney disease Smoking status
## Length :50 Length :50
## N.unique : 2 N.unique : 2
## N.blank : 0 N.blank : 0
## Min.nchar: 2 Min.nchar: 2
## Max.nchar: 3 Max.nchar: 3
##
## Body Mass Index (BMI) Physical activity level CKD Status
## Min. :15.20 Length :50 Length :50
## 1st Qu.:18.88 N.unique : 3 N.unique : 2
## Median :25.10 N.blank : 0 N.blank : 0
## Mean :26.33 Min.nchar: 3 Min.nchar: 2
## 3rd Qu.:32.00 Max.nchar: 8 Max.nchar: 3
## Max. :39.00
# Memilih data numerik
data_numerik <- data_ckd[sapply(data_ckd, is.numeric)]
# Statistik deskriptif data numerik
statistik_deskriptif <- data.frame(
Mean = sapply(data_numerik, mean, na.rm = TRUE),
Median = sapply(data_numerik, median, na.rm = TRUE),
Standar_Deviasi = sapply(data_numerik, sd, na.rm = TRUE),
Minimum = sapply(data_numerik, min, na.rm = TRUE),
Maksimum = sapply(data_numerik, max, na.rm = TRUE)
)
# Menampilkan hasil statistik deskriptif
statistik_deskriptif
## Mean Median Standar_Deviasi
## Age of the patient 56.9000 54.50000 20.076639
## Blood pressure (mm/Hg) 131.9000 127.50000 29.449542
## Blood urea (mg/dl) 101.2663 97.61756 58.013370
## Serum creatinine (mg/dl) 7.6134 8.17000 3.884868
## Hemoglobin level (gms) 12.0920 11.85000 3.368451
## Urine protein-to-creatinine ratio 2.3004 2.38000 1.232517
## Urine output (ml/day) 1739.5200 1740.50000 802.086062
## Cholesterol level 199.5200 214.00000 66.917933
## Body Mass Index (BMI) 26.3260 25.10000 7.641397
## Minimum Maksimum
## Age of the patient 25.000000 90.0000
## Blood pressure (mm/Hg) 80.000000 179.0000
## Blood urea (mg/dl) 8.685189 198.7258
## Serum creatinine (mg/dl) 0.760000 14.5800
## Hemoglobin level (gms) 6.000000 17.5000
## Urine protein-to-creatinine ratio 0.240000 4.4900
## Urine output (ml/day) 308.000000 2933.0000
## Cholesterol level 100.000000 298.0000
## Body Mass Index (BMI) 15.200000 39.0000
# ==============================
# DISTRIBUSI DATA KATEGORIK
# ==============================
# Memilih data kategorik
data_kategorik <- data_ckd[sapply(data_ckd, is.character)]
# Menampilkan jumlah setiap kategori
lapply(data_kategorik, table)
## $`Red blood cells in urine`
##
## abnormal normal
## 25 25
##
## $`Bacteria in urine`
##
## not present present
## 26 24
##
## $`Hypertension (yes/no)`
##
## no yes
## 32 18
##
## $`Diabetes mellitus (yes/no)`
##
## no yes
## 27 23
##
## $`Coronary artery disease (yes/no)`
##
## no yes
## 27 23
##
## $`Anemia (yes/no)`
##
## no yes
## 17 33
##
## $`Family history of chronic kidney disease`
##
## no yes
## 33 17
##
## $`Smoking status`
##
## no yes
## 26 24
##
## $`Physical activity level`
##
## high low moderate
## 17 16 17
##
## $`CKD Status`
##
## No Yes
## 31 19
# ============================================
# MENENTUKAN DISTRIBUSI DATASET CKD
# ============================================
# Install package jika belum ada
# install.packages("readxl")
# install.packages("ggplot2")
# Memanggil package
library(readxl)
library(ggplot2)
# Membaca dataset
CKD <- read_excel("CKD.xlsx")
# Melihat struktur data
str(CKD)
## tibble [50 × 19] (S3: tbl_df/tbl/data.frame)
## $ Age of the patient : num [1:50] 54 42 38 67 67 42 84 49 65 25 ...
## $ Blood pressure (mm/Hg) : num [1:50] 167 127 148 174 100 138 104 113 126 174 ...
## $ Red blood cells in urine : chr [1:50] "normal" "normal" "abnormal" "normal" ...
## $ Bacteria in urine : chr [1:50] "not present" "present" "not present" "not present" ...
## $ Blood urea (mg/dl) : num [1:50] 169.1 183.2 193.1 197.2 27.3 ...
## $ Serum creatinine (mg/dl) : num [1:50] 7.55 13.37 9.49 3.01 8.73 ...
## $ Hemoglobin level (gms) : num [1:50] 11.8 8.2 10.1 16.1 7.7 8.8 7.2 12.6 7.5 15.6 ...
## $ Hypertension (yes/no) : chr [1:50] "yes" "no" "no" "no" ...
## $ Diabetes mellitus (yes/no) : chr [1:50] "yes" "yes" "no" "no" ...
## $ Coronary artery disease (yes/no) : chr [1:50] "no" "no" "yes" "no" ...
## $ Anemia (yes/no) : chr [1:50] "no" "yes" "no" "yes" ...
## $ Urine protein-to-creatinine ratio : num [1:50] 2.51 4.27 1.56 1.23 2.61 2.42 1.67 0.41 2.8 0.46 ...
## $ Urine output (ml/day) : num [1:50] 1397 1632 889 893 1212 ...
## $ Cholesterol level : num [1:50] 152 242 103 149 182 260 134 229 276 206 ...
## $ Family history of chronic kidney disease: chr [1:50] "no" "yes" "no" "no" ...
## $ Smoking status : chr [1:50] "yes" "no" "no" "yes" ...
## $ Body Mass Index (BMI) : num [1:50] 25.3 20.6 38.4 17.6 37.2 23.5 23 30.6 16.8 28.5 ...
## $ Physical activity level : chr [1:50] "low" "moderate" "high" "high" ...
## $ CKD Status : chr [1:50] "Yes" "Yes" "No" "Yes" ...
# Melihat nama variabel
names(CKD)
## [1] "Age of the patient"
## [2] "Blood pressure (mm/Hg)"
## [3] "Red blood cells in urine"
## [4] "Bacteria in urine"
## [5] "Blood urea (mg/dl)"
## [6] "Serum creatinine (mg/dl)"
## [7] "Hemoglobin level (gms)"
## [8] "Hypertension (yes/no)"
## [9] "Diabetes mellitus (yes/no)"
## [10] "Coronary artery disease (yes/no)"
## [11] "Anemia (yes/no)"
## [12] "Urine protein-to-creatinine ratio"
## [13] "Urine output (ml/day)"
## [14] "Cholesterol level"
## [15] "Family history of chronic kidney disease"
## [16] "Smoking status"
## [17] "Body Mass Index (BMI)"
## [18] "Physical activity level"
## [19] "CKD Status"
# ============================================
# MEMILIH VARIABEL NUMERIK
# ============================================
data_numeric <- CKD[, sapply(CKD, is.numeric)]
# Melihat variabel numerik
names(data_numeric)
## [1] "Age of the patient" "Blood pressure (mm/Hg)"
## [3] "Blood urea (mg/dl)" "Serum creatinine (mg/dl)"
## [5] "Hemoglobin level (gms)" "Urine protein-to-creatinine ratio"
## [7] "Urine output (ml/day)" "Cholesterol level"
## [9] "Body Mass Index (BMI)"
# ============================================
# HISTOGRAM DISTRIBUSI DATA
# ============================================
for(i in names(data_numeric)){
print(
ggplot(CKD, aes(x = .data[[i]])) +
geom_histogram(
bins = 10,
fill = "skyblue",
color = "black"
) +
labs(
title = paste("Histogram Distribusi", i),
x = i,
y = "Frekuensi"
) +
theme_minimal()
)
}









# ============================================
# DENSITY PLOT MELIHAT BENTUK DISTRIBUSI
# ============================================
for(i in names(data_numeric)){
print(
ggplot(CKD, aes(x = .data[[i]])) +
geom_density(
fill = "skyblue",
alpha = 0.5
) +
labs(
title = paste("Density Plot Distribusi", i),
x = i,
y = "Density"
) +
theme_minimal()
)
}









# ============================================
# BOXPLOT UNTUK MELIHAT OUTLIER
# ============================================
for(i in names(data_numeric)){
print(
ggplot(CKD, aes(y = .data[[i]])) +
geom_boxplot(
fill = "orange"
) +
labs(
title = paste("Boxplot", i),
y = i
) +
theme_minimal()
)
}









# ============================================
# QQ PLOT DAN UJI NORMALITAS
# ============================================
for(i in names(data_numeric)){
# QQ Plot
qqnorm(
data_numeric[[i]],
main = paste("QQ Plot", i)
)
qqline(
data_numeric[[i]],
col = "red"
)
# Shapiro-Wilk Test
print(
shapiro.test(data_numeric[[i]])
)
}

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.94757, p-value = 0.02714

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.94638, p-value = 0.02427

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.93536, p-value = 0.008867

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.95717, p-value = 0.06766

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.94838, p-value = 0.02928

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.95861, p-value = 0.07771

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.92942, p-value = 0.005256

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.90099, p-value = 0.0005181

##
## Shapiro-Wilk normality test
##
## data: data_numeric[[i]]
## W = 0.91864, p-value = 0.002107
# Memanggil package
library(readxl)
library(ggplot2)
library(reshape2)
# Input data CKD
data_ckd <- read_excel(file.choose())
# Melihat struktur data
str(data_ckd)
## tibble [50 × 19] (S3: tbl_df/tbl/data.frame)
## $ Age of the patient : num [1:50] 54 42 38 67 67 42 84 49 65 25 ...
## $ Blood pressure (mm/Hg) : num [1:50] 167 127 148 174 100 138 104 113 126 174 ...
## $ Red blood cells in urine : chr [1:50] "normal" "normal" "abnormal" "normal" ...
## $ Bacteria in urine : chr [1:50] "not present" "present" "not present" "not present" ...
## $ Blood urea (mg/dl) : num [1:50] 169.1 183.2 193.1 197.2 27.3 ...
## $ Serum creatinine (mg/dl) : num [1:50] 7.55 13.37 9.49 3.01 8.73 ...
## $ Hemoglobin level (gms) : num [1:50] 11.8 8.2 10.1 16.1 7.7 8.8 7.2 12.6 7.5 15.6 ...
## $ Hypertension (yes/no) : chr [1:50] "yes" "no" "no" "no" ...
## $ Diabetes mellitus (yes/no) : chr [1:50] "yes" "yes" "no" "no" ...
## $ Coronary artery disease (yes/no) : chr [1:50] "no" "no" "yes" "no" ...
## $ Anemia (yes/no) : chr [1:50] "no" "yes" "no" "yes" ...
## $ Urine protein-to-creatinine ratio : num [1:50] 2.51 4.27 1.56 1.23 2.61 2.42 1.67 0.41 2.8 0.46 ...
## $ Urine output (ml/day) : num [1:50] 1397 1632 889 893 1212 ...
## $ Cholesterol level : num [1:50] 152 242 103 149 182 260 134 229 276 206 ...
## $ Family history of chronic kidney disease: chr [1:50] "no" "yes" "no" "no" ...
## $ Smoking status : chr [1:50] "yes" "no" "no" "yes" ...
## $ Body Mass Index (BMI) : num [1:50] 25.3 20.6 38.4 17.6 37.2 23.5 23 30.6 16.8 28.5 ...
## $ Physical activity level : chr [1:50] "low" "moderate" "high" "high" ...
## $ CKD Status : chr [1:50] "Yes" "Yes" "No" "Yes" ...
# ===============================
# HEATMAP KORELASI
# ===============================
# Mengambil variabel numerik
data_numerik <- data_ckd[
sapply(data_ckd, is.numeric)
]
# Matriks korelasi
cor_ckd <- cor(
data_numerik,
use = "complete.obs"
)
cor_ckd
## Age of the patient Blood pressure (mm/Hg)
## Age of the patient 1.000000000 -0.056452726
## Blood pressure (mm/Hg) -0.056452726 1.000000000
## Blood urea (mg/dl) -0.354371274 0.005261570
## Serum creatinine (mg/dl) -0.109526242 -0.129086086
## Hemoglobin level (gms) -0.265302082 0.286139953
## Urine protein-to-creatinine ratio -0.002406608 0.007242955
## Urine output (ml/day) -0.026039203 -0.162983531
## Cholesterol level -0.121651131 0.202057857
## Body Mass Index (BMI) 0.183408473 -0.120368241
## Blood urea (mg/dl) Serum creatinine (mg/dl)
## Age of the patient -0.35437127 -0.10952624
## Blood pressure (mm/Hg) 0.00526157 -0.12908609
## Blood urea (mg/dl) 1.00000000 -0.08488131
## Serum creatinine (mg/dl) -0.08488131 1.00000000
## Hemoglobin level (gms) 0.01166014 -0.24292319
## Urine protein-to-creatinine ratio -0.22136013 -0.07526920
## Urine output (ml/day) 0.24168246 0.05930546
## Cholesterol level 0.06532990 0.06440695
## Body Mass Index (BMI) -0.13613850 0.25197942
## Hemoglobin level (gms)
## Age of the patient -0.26530208
## Blood pressure (mm/Hg) 0.28613995
## Blood urea (mg/dl) 0.01166014
## Serum creatinine (mg/dl) -0.24292319
## Hemoglobin level (gms) 1.00000000
## Urine protein-to-creatinine ratio -0.15416868
## Urine output (ml/day) -0.05550967
## Cholesterol level 0.17145262
## Body Mass Index (BMI) -0.16341770
## Urine protein-to-creatinine ratio
## Age of the patient -0.002406608
## Blood pressure (mm/Hg) 0.007242955
## Blood urea (mg/dl) -0.221360129
## Serum creatinine (mg/dl) -0.075269196
## Hemoglobin level (gms) -0.154168675
## Urine protein-to-creatinine ratio 1.000000000
## Urine output (ml/day) -0.182253569
## Cholesterol level -0.043586517
## Body Mass Index (BMI) -0.161207444
## Urine output (ml/day) Cholesterol level
## Age of the patient -0.02603920 -0.12165113
## Blood pressure (mm/Hg) -0.16298353 0.20205786
## Blood urea (mg/dl) 0.24168246 0.06532990
## Serum creatinine (mg/dl) 0.05930546 0.06440695
## Hemoglobin level (gms) -0.05550967 0.17145262
## Urine protein-to-creatinine ratio -0.18225357 -0.04358652
## Urine output (ml/day) 1.00000000 0.15575661
## Cholesterol level 0.15575661 1.00000000
## Body Mass Index (BMI) -0.02057504 -0.28271003
## Body Mass Index (BMI)
## Age of the patient 0.18340847
## Blood pressure (mm/Hg) -0.12036824
## Blood urea (mg/dl) -0.13613850
## Serum creatinine (mg/dl) 0.25197942
## Hemoglobin level (gms) -0.16341770
## Urine protein-to-creatinine ratio -0.16120744
## Urine output (ml/day) -0.02057504
## Cholesterol level -0.28271003
## Body Mass Index (BMI) 1.00000000
# Mengubah matriks menjadi format tabel
data_cor <- melt(cor_ckd)
# Membuat heatmap korelasi
ggplot(data_cor, aes(Var1, Var2, fill = value))+
geom_tile(color = "black") +
geom_text(
aes(label = round(value, 2)),
color = "black"
) +
scale_fill_gradient2(
low = "red",
high = "green",
mid = "yellow",
midpoint = 0,
limit = c(-1,1),
name = "Korelasi"
) +
theme_minimal() +
labs(
title = "Heatmap Korelasi Variabel Numerik Dataset CKD",
x = "Variabel",
y = "Variabel"
) +
theme(
plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(angle = 45, hjust = 1)
)

# ===============================
# TABEL KONTINGENSI
# ===============================
# Tabel kontingensi Status CKD dengan Hipertensi
tabel_hipertensi <- table(
data_ckd$`Hypertension (yes/no)`,
data_ckd$`CKD Status`
)
tabel_hipertensi
##
## No Yes
## no 21 11
## yes 10 8
# Tabel kontingensi Status CKD dengan Diabetes
tabel_diabetes <- table(
data_ckd$`Diabetes mellitus (yes/no)`,
data_ckd$`CKD Status`
)
tabel_diabetes
##
## No Yes
## no 18 9
## yes 13 10
# Tabel kontingensi Status CKD dengan Anemia
tabel_anemia <- table(
data_ckd$`Anemia (yes/no)`,
data_ckd$`CKD Status`
)
tabel_anemia
##
## No Yes
## no 11 6
## yes 20 13