fbg <- 112
if (fbg < 100) {
result <- "Normal"
} else if (fbg >= 100 & fbg <= 125) {
result <- "Prediabetes"
} else {
result <- "Diabetes"
}
cat("Glucose Level Classification:", result, "\n")## Glucose Level Classification: Prediabetes
temperature <- 38.2
if (temperature > 37.5) {
cat("Fever Detected\n")
} else {
cat("Normal Temperature\n")
}## Fever Detected
bmi <- 29.5
if (bmi < 25) {
bmi_class <- "Normal"
} else if (bmi >= 25 & bmi <= 29.9) {
bmi_class <- "Overweight"
} else {
bmi_class <- "Obese"
}
cat("BMI Classification:", bmi_class, "\n")## BMI Classification: Overweight
## Anemia
patients <- data.frame(
Name = c("Aisha", "Rahman", "Rima", "Hossain"),
Age = c(45, 52, 37, 60),
BMI = c(31.2, 28.5, 24.1, 33.4),
BP_Systolic = c(150, 165, 120, 175),
stringsAsFactors = FALSE
)
print(patients)## Name Age BMI BP_Systolic
## 1 Aisha 45 31.2 150
## 2 Rahman 52 28.5 165
## 3 Rima 37 24.1 120
## 4 Hossain 60 33.4 175
## Name Age BMI BP_Systolic Hypertensive
## 1 Aisha 45 31.2 150 Yes
## 2 Rahman 52 28.5 165 Yes
## 3 Rima 37 24.1 120 No
## 4 Hossain 60 33.4 175 Yes
patients$BMI_Status <- ifelse(patients$BMI >= 30, "Obese",
ifelse(patients$BMI >= 25 & patients$BMI <= 29.9, "Overweight", "Normal"))
print(patients)## Name Age BMI BP_Systolic Hypertensive BMI_Status
## 1 Aisha 45 31.2 150 Yes Obese
## 2 Rahman 52 28.5 165 Yes Overweight
## 3 Rima 37 24.1 120 No Normal
## 4 Hossain 60 33.4 175 Yes Obese
## Name Age BMI BP_Systolic Hypertensive BMI_Status
## 2 Rahman 52 28.5 165 Yes Overweight
## 4 Hossain 60 33.4 175 Yes Obese
# Count how many risk conditions are met for each patient
risk_conditions <- (patients$Age > 50) + (patients$Hypertensive == "Yes")
patients$Risk_Level <- ifelse(risk_conditions == 2, "High Risk",
ifelse(risk_conditions == 1, "Moderate Risk", "Low Risk"))
print(patients)## Name Age BMI BP_Systolic Hypertensive BMI_Status Risk_Level
## 1 Aisha 45 31.2 150 Yes Obese Moderate Risk
## 2 Rahman 52 28.5 165 Yes Overweight High Risk
## 3 Rima 37 24.1 120 No Normal Low Risk
## 4 Hossain 60 33.4 175 Yes Obese High Risk
## Please upload lab data for Day 1
## Please upload lab data for Day 2
## Please upload lab data for Day 3
## Please upload lab data for Day 4
## Please upload lab data for Day 5
## Please upload lab data for Day 6
## Please upload lab data for Day 7
## Processing year: 2015
## Processing year: 2016
## Processing year: 2017
## Processing year: 2018
## Processing year: 2019
## Processing year: 2020
## Processing year: 2021
## Processing year: 2022
## Processing year: 2023
## Processing year: 2024
## Processing year: 2025
# 1. Create the data frame
hiv_data <- data.frame(
Name = c("Rahim", "Sumaiya", "Babul", "Joya"),
CD4_Count = c(120, 480, 230, 700),
stringsAsFactors = FALSE
)
# 2. Add Immunity_Status column
hiv_data$Immunity_Status <- ifelse(hiv_data$CD4_Count < 200, "Severe Immunodeficiency",
ifelse(hiv_data$CD4_Count >= 200 & hiv_data$CD4_Count <= 500, "Moderate", "Normal"))
print("Full HIV Dataset:")## [1] "Full HIV Dataset:"
## Name CD4_Count Immunity_Status
## 1 Rahim 120 Severe Immunodeficiency
## 2 Sumaiya 480 Moderate
## 3 Babul 230 Moderate
## 4 Joya 700 Normal
# 3. Print only "Severe" cases
severe_cases <- subset(hiv_data, Immunity_Status == "Severe Immunodeficiency")
print("Severe Cases Only:")## [1] "Severe Cases Only:"
## Name CD4_Count Immunity_Status
## 1 Rahim 120 Severe Immunodeficiency
scores <- c(10, 35, 50, 80, 95)
Severity_Label <- character(length(scores))
# 1. Use a for loop and if-else to assign severity
for (i in seq_along(scores)) {
if (scores[i] < 30) {
Severity_Label[i] <- "Mild"
} else if (scores[i] >= 30 & scores[i] <= 70) {
Severity_Label[i] <- "Moderate"
} else {
Severity_Label[i] <- "Severe"
}
}
# 2 & 3. Store results and combine in a data frame
scoring_df <- data.frame(
Infection_Score = scores,
Severity_Label = Severity_Label,
stringsAsFactors = FALSE
)
print(scoring_df)## Infection_Score Severity_Label
## 1 10 Mild
## 2 35 Moderate
## 3 50 Moderate
## 4 80 Severe
## 5 95 Severe
# 1. Create the data frame
ward_data <- data.frame(
Name = c("Mina", "Rafi", "Sima", "Rony", "Asha", "Nayeem"),
Age = c(25, 50, 61, 45, 70, 58),
Temp = c(36.8, 38.5, 39.2, 37.0, 38.0, 36.5),
SpO2 = c(99, 95, 91, 98, 89, 97),
stringsAsFactors = FALSE
)
# 2 & 3. Write a loop to classify each patient and add "Condition" column
ward_data$Condition <- character(nrow(ward_data))
for (i in 1:nrow(ward_data)) {
if (ward_data$Temp[i] > 38 & ward_data$SpO2[i] < 94) {
ward_data$Condition[i] <- "Critical"
} else if (ward_data$Temp[i] > 37 & ward_data$SpO2[i] < 96) {
ward_data$Condition[i] <- "At Risk"
} else {
ward_data$Condition[i] <- "Stable"
}
}
print("Hospital Ward Data with Conditions:")## [1] "Hospital Ward Data with Conditions:"
## Name Age Temp SpO2 Condition
## 1 Mina 25 36.8 99 Stable
## 2 Rafi 50 38.5 95 At Risk
## 3 Sima 61 39.2 91 Critical
## 4 Rony 45 37.0 98 Stable
## 5 Asha 70 38.0 89 At Risk
## 6 Nayeem 58 36.5 97 Stable
# 4. Print a summary table of how many patients fall into each category
print("Summary Table of Conditions:")## [1] "Summary Table of Conditions:"
##
## At Risk Critical Stable
## 2 1 3