---
title: "Beo phi 2025-10-21"
author: "MHuong"
date: "2025-10-21"
output: html_document
---
ob = read.csv("D:\\2025-10-Tap huan_Phan  tich du lieu va cong bo Quoc te danh cho giang vien\\Obesity data.csv")

```Kích thước dữ liệu
dim(ob)

Số dòng

nrow(ob)

Số cột

ncol(ob)

6 quan sát đầu

head(ob)

6 quan sát cuối

tail(ob)

Tóm tắt dữ liệu

summary(ob)

Tạo biến sex

ob\(sex <- ifelse(ob\)gender == “F”, 1, 0)

Phân loại BMI

ob\(obese <- cut(ob\)bmi, breaks = c(-Inf, 18.5, 25.0, 30.0, Inf), labels = c(“Underweight”, “Normal”, “Overweight”, “Obese”), right = FALSE)

Xem tên biến và kích thước

names(ob) dim(ob)

Xem một vài biến

head(ob\(weight) head(ob\)FatPercent)

Tính toán khối lượng mỡ và nạc

ob\(fat.kg <- ob\)weight * ob\(pcfat / 100 ob\)lean.kg <- ob\(weight - ob\)fat.kg

Lọc nam giới thừa cân

men.overweight <- subset(ob, gender == “M” & bmi >= 25.0) dim(men.overweight)

Lấy dữ liệu demo

Demo <- ob[, c(“id”, “age”, “gender”, “height”, “weight”, “pcfat”)]