Goal: Implement the S3 class ChlorReads. Here is the ChlorReads UML diagram.
Relevent Examples: Kid in the 5/18 Notes and Die
> p1 <- ChlorReads(9876, "Virgil", "M", 248, 45, 148) > print(p1) ID: 9876 Name: Virgil Gender: M LDL: 248* HDL: 45+ Triglycerides: 148* means high risk value, + means borderline. Use these cutoff values the three chloresterol values:
Type | Range | Meaning | Symbol |
---|---|---|---|
LDL | 0 to 200 | Normal | "" |
LDL | 200 to 240 | Borderline | "+" |
LDL | 240 and up | High Risk | "*" |
HDL | 0 to 40 | High Risk | "*" |
HDL | 40 to 60 | Borderline | "+" |
HDL | 60 and up | Normal | " " |
Trigl | 0 to 150 | Normal | "" |
Trigl | 150 to 200 | Borderline | "+" |
Trigl | 200 and up | High Risk | "*" |
# Correct if (score >= 90) { grade = "A" } else if (score >= 80) { grade = "B" } else { grade = "C" } # Incorrect if (score >= 90) { grade = "A" } else if (score >= 80) { grade = "B" } else { grade = "C" }
> getPatientInfo(p1) ID Name Gender 9876 Virgil M > getChloresterol(p1) LDL HDL Trigl 208 45 148
lst <- NULL chlor <- read.table("chlor-reads.txt") for(i in 1:nrow(chlor)) { lst[[i]] <- ChlorReads(chlor[i, ]$id, as.character(chlor[i, ]$name), as.character(chlor[i, ]$gender), chlor[i, ]$ldl, chlor[i, ]$hdl, chlor[i, ]$trigl) }The as.character method calls for the name and gender components are because these components are stored as factor objects in a data frame.