Module #4

 This week we were asked to create a boxplot and histogram of faux local hospital data. As well as discuss the outcome of our results regarding patients' BPs & MD’s Ratings.

From the first graph (boxplot), we can observe that patients with a higher final decision had visited the hospital more frequently than the lower final decision. We can also observe that those with higher blood pressure visited the hospital more frequently than those with lower blood pressure. 

The second graph (histogram), displays that there were more "bad" first assessments with the patients with one N/A.  
The second graph (histogram2), displays that there were more "high" blood pressure assesments by doctor #2.  

library(ggplot2)

#Data 

p1<- c(0.6,103,'bad','low','low')

p2<- c(0.3,87,'bad','low','high')

p3<- c(0.4,32,'bad','high','low')

p4<- c(0.4,42,'bad','high','high')

p5<- c(0.2,59,'good','low','low')

p6<- c(0.6,109,'good','low','high')

p7<- c(0.3,78,'good','high','low')

p8<- c(0.4,205,'good','high','high')

p9<- c(0.9,135,NA,'high','high')

p10<- c(0.2, 176,'bad','high','high')


#Column names

cnam <- c('Freq','bloodp','first', 'second', 'finaldecision')


#Create data frame from patient information

pat <- data.frame(p1,p2,p3, p4, p5, p6, p7, p8, p9, p10)


#Transpose data frame

pat2 <- as.data.frame(t(pat))


#Checks for NA

is.na.data.frame(pat2)


#Assign column names and convert numbers to numeric

colnames(pat2) <- cnam

pat2$Freq <- as.numeric(pat2$Freq)

pat2$bloodp <- as.numeric(pat2$bloodp)


#Preview

str(pat2)


bpl <- ggplot(pat2, aes(bloodp, Freq, group=finaldecision, fill=finaldecision)) +

        geom_boxplot()

bpl



hpl <- ggplot(pat2, aes(first, fill=first))+

        geom_histogram(stat = "count")

hpl



hpl2 <- ggplot(pat2, aes(second, fill=second))+

        geom_histogram(stat = "count")

hpl2



Comments

Popular posts from this blog

Module #6