Module #4

First, I entered the data and created a data frame:

 

Freq <- c(0.6, 0.3, 0.4, 0.4, 0.2, 0.6, 0.3, 0.4, 0.9, 0.2)

bloodp <- 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", "high", "high", "high", "high", "high")

finaldecision <- c("low", "high", "low", "high", "low", "high", "low", "high", "high", "high")

 

first <- factor(first, levels = c("bad", "good"))

second <- factor(second, levels = c("low", "high"))

finaldecision <- factor(finaldecision, levels = c("low", "high"))

 

data <- data.frame(Freq, bloodp, first, second, finaldecision)

 

Then created boxplots:

par(mfrow = c(1, 2), mar = c(3, 3, 1, 1)) 

 

 

boxplot(Freq ~ first, data = data, main = "Boxplot of 'first'", col = c("red", "blue"))

boxplot(Freq ~ second, data = data, main = "Boxplot of 'second'", col = c("red", "blue"))




 

And finally, created histograms:

 

par(mfrow = c(1, 1), mar = c(5, 4, 4, 2)) 

 

 

hist(Freq[data$first == "bad"], main = "Histogram of Frequency 1", xlab = "Frequency")

hist(Freq[data$first == "good"], main = "Histogram of Frequency 2", xlab = "Frequency")







There's a wide range of low and high blood pressures. The side-by-side boxplots and histograms show the range of values and doctor's ranking of 'good' or 'bad'.

Comments