Homework 05

Reading Data

dat = read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_IMSE.csv")
names(dat)
##  [1] "Unique.Identifier"           "PatientAge"                 
##  [3] "Radiology.Technician"        "CatalogCode"                
##  [5] "Ordering.Physician"          "PatientTypeMnemonic"        
##  [7] "Priority"                    "OrderDateTime"              
##  [9] "ExamCompleteDateTime"        "FinalDateTime"              
## [11] "Ordered.to.Complete...Mins"  "Ordered.to.Complete...Hours"
## [13] "Loc.At.Exam.Complete"        "Exam.Completed.Bucket"      
## [15] "Section"                     "Exam.Room"
str(dat)
## 'data.frame':    43632 obs. of  16 variables:
##  $ Unique.Identifier          : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ PatientAge                 : int  75 87 35 51 67 54 34 65 67 40 ...
##  $ Radiology.Technician       : int  65 65 16 24 37 7 40 2 2 34 ...
##  $ CatalogCode                : chr  "DX Abdomen 2 vw w/single chest" "DX Abdomen 2 vw w/single chest" "DX Abdomen 2 vw w/single chest" "DX Abdomen 2 vw w/single chest" ...
##  $ Ordering.Physician         : int  4 4 150 130 173 349 4 4 39 4 ...
##  $ PatientTypeMnemonic        : chr  "IP" "IP" "IP" "IP" ...
##  $ Priority                   : chr  "Routine" "Routine" "Routine" "Routine" ...
##  $ OrderDateTime              : chr  "12/27/16 10:32" "1/13/17 11:44" "1/2/17 17:19" "11/13/16 10:13" ...
##  $ ExamCompleteDateTime       : chr  "12/27/16 11:19" "1/13/17 12:32" "1/2/17 18:00" "11/14/16 9:34" ...
##  $ FinalDateTime              : chr  "12/28/16 14:32" "1/14/17 16:00" "1/3/17 7:44" "11/14/16 16:40" ...
##  $ Ordered.to.Complete...Mins : int  47 48 41 1401 42 129 42 1068 49 47 ...
##  $ Ordered.to.Complete...Hours: num  0.783 0.8 0.683 23.35 0.7 ...
##  $ Loc.At.Exam.Complete       : chr  "GTU" "GTU" "3W" "4W" ...
##  $ Exam.Completed.Bucket      : chr  "8a-8p" "8a-8p" "8a-8p" "8a-8p" ...
##  $ Section                    : chr  "DX" "DX" "EC DX" "DX" ...
##  $ Exam.Room                  : chr  "DX Rm 1" "DX Rm 1" "DX Rm 5 (EC)" "DX Rm 1" ...
dat = dat[dat$Ordered.to.Complete...Mins >=0,] 

Question 01

medicare = dat[dat$PatientAge >=65,]
summary(medicare$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0      21      38    1786      90  112168
medicare.iqr = medicare[medicare$Ordered.to.Complete...Mins >= 21 & medicare$Ordered.to.Complete...Mins <= 90,]
hist(medicare.iqr$Ordered.to.Complete...Mins,
     main = "X-ray Completion Times for Medicare Patients",
     xlab = "Completion Time in Minutes",
     ylab = "Number of Observations",
     col = "lightblue",
     border = "black")

This filters the data to patients age 65 or older, then restricts completion times to the middle 50% of observations using Q1 and Q3. The histogram should look slightly tilted downwards to the right, meaning most completion times are lower/middle values, with some longer times stretching the right side.

Question 02

tech62 = dat[dat$Radiology.Technician == 62,]
tech65 = dat[dat$Radiology.Technician == 65,]
summary(tech62$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   13.00   48.00   80.00   76.88  117.00  118.00
summary(tech65$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     1.0    16.0    27.0    94.9    45.0 35306.0

This shows Technician 62 had a median completion time of 80 minutes, while Technician 65 had a median completion time of 27 minutes. That means Technician 65 appears faster based on median completion time.

Question 03

boxplot(dat$PatientAge ~ dat$Priority,
        main = "Patient Age by X-Ray Order Priority" ,
        xlab = "Order Priority" ,
        ylab = "Patient Age" ,
        col = c("red", "green"))

This boxplot compares patient ages for STAT and Routine X-Ray orders. It shows which group usually has older or younger patients, and which group has more spread or outliers. In the output, STAT has a wider age range, while Routine has several outliers.

Question 04

mean(dat[dat$Loc.At.Exam.Complete == "3W", ]$Ordered.to.Complete...Mins)
## [1] 1463.051
sd(dat[dat$Loc.At.Exam.Complete == "3W", ]$Ordered.to.Complete...Mins)
## [1] 3894.639
mean(dat[dat$Loc.At.Exam.Complete == "4W", ]$Ordered.to.Complete...Mins)
## [1] 1675.451
sd(dat[dat$Loc.At.Exam.Complete == "4W", ]$Ordered.to.Complete...Mins)
## [1] 4387.644

Floor 3W had a lower average completion time than floor 4W, so X-Ray orders were completed faster on average on 3W. Both floors had very large standard deviations, which means the completion times varied a lot and some orders likely took much longer than others.