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


[Histogram



Blood Pressure vs. First Assessment (bad=1, good=0):

From the boxplot, you can compare the distribution of blood pressure between patients rated as "bad" and "good" by the first assessment. Look at the medians, quartiles, and potential outliers in each group.
This analysis may reveal if there is a notable difference in blood pressure based on the initial assessment by the general doctor.

Blood Pressure vs. Second Assessment (low=0, high=1):

Similar to the first boxplot, this one compares the distribution of blood pressure between patients with a "low" and "high" second assessment.
This analysis helps identify any patterns or differences in blood pressure concerning the external doctor's assessment.

Histogram of Blood Pressure:

The histogram gives an overall view of the distribution of blood pressure across all patients.
It helps identify the most common range of blood pressure values and whether there are any outliers.



Comments

Popular posts from this blog

Final Project [LIS4317]

Module # 7 assignment (Visual Analytics)

Module # 8 Input/Output, string manipulation and plyr package