1. Import Data
data_obesity <- read.csv(
file.choose(),
sep = ";",
header = TRUE
)
2. Melihat Data
head(data_obesity)
## Gender Age Height Weight family_history_with_overweight FAVC FCVC NCP
## 1 Female 21 1.62 64.0 yes no 2 3
## 2 Female 21 1.52 56.0 yes no 3 3
## 3 Male 23 1.80 77.0 yes no 2 3
## 4 Male 27 1.80 87.0 no no 3 3
## 5 Male 22 1.78 89.8 no no 2 1
## 6 Male 29 1.62 53.0 no yes 2 3
## CAEC SMOKE CH2O SCC FAF TUE CALC MTRANS
## 1 Sometimes no 2 no 0 1 no Public_Transportation
## 2 Sometimes yes 3 yes 3 0 Sometimes Public_Transportation
## 3 Sometimes no 2 no 2 1 Frequently Public_Transportation
## 4 Sometimes no 2 no 2 0 Frequently Walking
## 5 Sometimes no 2 no 0 0 Sometimes Public_Transportation
## 6 Sometimes no 2 no 0 0 Sometimes Automobile
## NObeyesdad
## 1 Normal_Weight
## 2 Normal_Weight
## 3 Normal_Weight
## 4 Overweight_Level_I
## 5 Overweight_Level_II
## 6 Normal_Weight
3. Struktur Data
str(data_obesity)
## 'data.frame': 2111 obs. of 17 variables:
## $ Gender : chr "Female" "Female" "Male" "Male" ...
## $ Age : num 21 21 23 27 22 29 23 22 24 22 ...
## $ Height : num 1.62 1.52 1.8 1.8 1.78 1.62 1.5 1.64 1.78 1.72 ...
## $ Weight : num 64 56 77 87 89.8 53 55 53 64 68 ...
## $ family_history_with_overweight: chr "yes" "yes" "yes" "no" ...
## $ FAVC : chr "no" "no" "no" "no" ...
## $ FCVC : num 2 3 2 3 2 2 3 2 3 2 ...
## $ NCP : num 3 3 3 3 1 3 3 3 3 3 ...
## $ CAEC : chr "Sometimes" "Sometimes" "Sometimes" "Sometimes" ...
## $ SMOKE : chr "no" "yes" "no" "no" ...
## $ CH2O : num 2 3 2 2 2 2 2 2 2 2 ...
## $ SCC : chr "no" "yes" "no" "no" ...
## $ FAF : num 0 3 2 2 0 0 1 3 1 1 ...
## $ TUE : num 1 0 1 0 0 0 0 0 1 1 ...
## $ CALC : chr "no" "Sometimes" "Frequently" "Frequently" ...
## $ MTRANS : chr "Public_Transportation" "Public_Transportation" "Public_Transportation" "Walking" ...
## $ NObeyesdad : chr "Normal_Weight" "Normal_Weight" "Normal_Weight" "Overweight_Level_I" ...
4. Ringkasan Data
summary(data_obesity)
## Gender Age Height Weight
## Length :2111 Min. :14.00 Min. :1.450 Min. : 39.00
## N.unique : 2 1st Qu.:19.95 1st Qu.:1.630 1st Qu.: 65.47
## N.blank : 0 Median :22.78 Median :1.700 Median : 83.00
## Min.nchar: 4 Mean :24.31 Mean :1.702 Mean : 86.59
## Max.nchar: 6 3rd Qu.:26.00 3rd Qu.:1.768 3rd Qu.:107.43
## Max. :61.00 Max. :1.980 Max. :173.00
## family_history_with_overweight FAVC FCVC
## Length :2111 Length :2111 Min. :1.000
## N.unique : 2 N.unique : 2 1st Qu.:2.000
## N.blank : 0 N.blank : 0 Median :2.386
## Min.nchar: 2 Min.nchar: 2 Mean :2.419
## Max.nchar: 3 Max.nchar: 3 3rd Qu.:3.000
## Max. :3.000
## NCP CAEC SMOKE CH2O
## Min. :1.000 Length :2111 Length :2111 Min. :1.000
## 1st Qu.:2.659 N.unique : 4 N.unique : 2 1st Qu.:1.585
## Median :3.000 N.blank : 0 N.blank : 0 Median :2.000
## Mean :2.686 Min.nchar: 2 Min.nchar: 2 Mean :2.008
## 3rd Qu.:3.000 Max.nchar: 10 Max.nchar: 3 3rd Qu.:2.477
## Max. :4.000 Max. :3.000
## SCC FAF TUE CALC
## Length :2111 Min. :0.0000 Min. :0.0000 Length :2111
## N.unique : 2 1st Qu.:0.1245 1st Qu.:0.0000 N.unique : 4
## N.blank : 0 Median :1.0000 Median :0.6253 N.blank : 0
## Min.nchar: 2 Mean :1.0103 Mean :0.6579 Min.nchar: 2
## Max.nchar: 3 3rd Qu.:1.6667 3rd Qu.:1.0000 Max.nchar: 10
## Max. :3.0000 Max. :2.0000
## MTRANS NObeyesdad
## Length :2111 Length :2111
## N.unique : 5 N.unique : 7
## N.blank : 0 N.blank : 0
## Min.nchar: 4 Min.nchar: 13
## Max.nchar: 21 Max.nchar: 19
##
5. Scatter Plot Umur vs Tinggi Badan
ggplot(data_obesity, aes(x = Age, y = Height)) +
geom_point(
alpha = 0.6,
size = 2
) +
geom_smooth(
method = "lm",
se = FALSE,
color = "red",
linewidth = 4
) +
labs(
title = "Hubungan Umur dan Tinggi Badan",
x = "Umur (tahun)",
y = "Tinggi Badan (m)"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

6. Scatter Plot Umur vs Berat Badan
ggplot(data_obesity, aes(x = Age, y = Weight)) +
geom_point(
alpha = 0.6,
size = 2
) +
geom_smooth(
method = "lm",
se = FALSE,
color = "red",
linewidth = 4
) +
labs(
title = "Hubungan Umur dan Berat Badan",
x = "Umur (tahun)",
y = "Berat Badan (kg)"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'

7. Scatter Plot Tinggi Badan vs Berat Badan
ggplot(data_obesity, aes(x = Height, y = Weight)) +
geom_point(
alpha = 0.6,
size = 2
) +
geom_smooth(
method = "lm",
se = FALSE,
color = "red",
linewidth = 4
) +
labs(
title = "Hubungan Tinggi Badan dan Berat Badan",
x = "Tinggi Badan (m)",
y = "Berat Badan (kg)"
) +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
