Module # 4 Programming structure in R [ R Programming ]
[CODE]
# Data
Frequency <- c(0.6, 0.3, 0.4, 0.4, 0.2, 0.6, 0.3, 0.4, 0.9, 0.2)
BloodPressure <- c(103, 87, 32, 42, 59, 109, 78, 205, 135, 176)
FirstAssessment <- c(1, 1, 1, 1, 0, 0, 0, 0, NA, 1)
SecondAssessment <- c(0, 0, 1, 1, 0, 1, 1, 1, 1, 1)
FinalDecision <- c(0, 1, 0, 1, 0, 1, 0, 1, 1, 1)
# Create a data frame
hospital_data <- data.frame(Frequency, BloodPressure, FirstAssessment, SecondAssessment, FinalDecision)
# Boxplot
par(mfrow=c(1,2)) # Set up a 1x2 grid for side-by-side plots
boxplot(BloodPressure ~ FirstAssessment, data=hospital_data, main="Blood Pressure vs. First Assessment", xlab="First Assessment", ylab="Blood Pressure")
boxplot(BloodPressure ~ SecondAssessment, data=hospital_data, main="Blood Pressure vs. Second Assessment", xlab="Second Assessment", ylab="Blood Pressure")
# Histogram
hist(BloodPressure, main="Histogram of Blood Pressure", xlab="Blood Pressure", ylab="Frequency", col="lightblue", border="black")
[Boxplot]
Comments
Post a Comment