Github link: https://github.com/rayhankhan-svg/r-programming-assignments
R Code:
# Create the data vectors
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)
First <- c("bad", "bad", "bad", "bad", "good", "good", "good", "good", NA, "bad")
Second <- c("low", "low", "high", "high", "low", "low", "high", "high", "high", "high")
FinalDecision <- c("low", "high", "low", "high", "low", "high", "low", "high", "high", "high")
# Create data frame
hospital_data <- data.frame(Frequency, BloodPressure, First, Second, FinalDecision)
hospital_data
# Create boxplot of Blood Pressure
boxplot(BloodPressure,
main="Boxplot of Patient Blood Pressure",
ylab="Blood Pressure",
col="lightblue")
# Create histogram of Blood Pressure
hist(BloodPressure,
main="Histogram of Patient Blood Pressure",
xlab="Blood Pressure",
col="lightgreen")
Output:
> # Create the data vectors
> 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)
>
> First <- c("bad", "bad", "bad", "bad", "good", "good", "good", "good", NA, "bad")
>
> Second <- c("low", "low", "high", "high", "low", "low", "high", "high", "high", "high")
>
> FinalDecision <- c("low", "high", "low", "high", "low", "high", "low", "high", "high", "high")
>
> # Create data frame
> hospital_data <- data.frame(Frequency, BloodPressure, First, Second, FinalDecision)
>
> hospital_data
Frequency BloodPressure First Second FinalDecision
1 0.6 103 bad low low
2 0.3 87 bad low high
3 0.4 32 bad high low
4 0.4 42 bad high high
5 0.2 59 good low low
6 0.6 109 good low high
7 0.3 78 good high low
8 0.4 205 good high high
9 0.9 135 <NA> high high
10 0.2 176 bad high high
>
>
> # Create boxplot of Blood Pressure
> boxplot(BloodPressure,
+ main="Boxplot of Patient Blood Pressure",
+ ylab="Blood Pressure",
+ col="lightblue")
>
>
> # Create histogram of Blood Pressure
> hist(BloodPressure,
+ main="Histogram of Patient Blood Pressure",
+ xlab="Blood Pressure",
+ col="lightgreen")
>


Explanation:
I developed a data frame using hospital patient information for this assignment, such as visit frequency, blood pressure readings, and physician evaluations. After that, I created a boxplot and a histogram to show how the blood pressure readings of the patients were distributed. The majority of patients had blood pressure readings in the moderate range, according to the boxplot and histogram, but some had higher readings that would point to possible health issues. The histogram displayed the frequency distribution of blood pressure readings, while the boxplot assisted in identifying the dispersion and any outliers. Higher blood pressure readings were more frequently linked to high-risk conclusions, suggesting that the doctors' assessments and ultimate choices were impacted by the data. This exercise showed how R's graphical capabilities, such as boxplots and histograms, may be used to effectively depict and interpret medical data.
Comments
Post a Comment