Load data

We are loading the data for X-Ray orders from a major US hospital.

dat <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_IMSE.csv")
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" ...
head(dat)
##   Unique.Identifier PatientAge Radiology.Technician
## 1                 1         75                   65
## 2                 2         87                   65
## 3                 3         35                   16
## 4                 4         51                   24
## 5                 5         67                   37
## 6                 6         54                    7
##                      CatalogCode Ordering.Physician PatientTypeMnemonic
## 1 DX Abdomen 2 vw w/single chest                  4                  IP
## 2 DX Abdomen 2 vw w/single chest                  4                  IP
## 3 DX Abdomen 2 vw w/single chest                150                  IP
## 4 DX Abdomen 2 vw w/single chest                130                  IP
## 5 DX Abdomen 2 vw w/single chest                173                  IP
## 6 DX Abdomen 2 vw w/single chest                349                  IP
##   Priority  OrderDateTime ExamCompleteDateTime  FinalDateTime
## 1  Routine 12/27/16 10:32       12/27/16 11:19 12/28/16 14:32
## 2  Routine  1/13/17 11:44        1/13/17 12:32  1/14/17 16:00
## 3  Routine   1/2/17 17:19         1/2/17 18:00    1/3/17 7:44
## 4  Routine 11/13/16 10:13        11/14/16 9:34 11/14/16 16:40
## 5     STAT  12/13/16 3:22        12/13/16 4:04  12/13/16 3:19
## 6  Routine   1/17/17 5:38         1/17/17 7:47  1/17/17 10:55
##   Ordered.to.Complete...Mins Ordered.to.Complete...Hours Loc.At.Exam.Complete
## 1                         47                   0.7833333                  GTU
## 2                         48                   0.8000000                  GTU
## 3                         41                   0.6833333                   3W
## 4                       1401                  23.3500000                   4W
## 5                         42                   0.7000000        Emergency Ctr
## 6                        129                   2.1500000                   3E
##   Exam.Completed.Bucket Section    Exam.Room
## 1                 8a-8p      DX      DX Rm 1
## 2                 8a-8p      DX      DX Rm 1
## 3                 8a-8p   EC DX DX Rm 5 (EC)
## 4                 8a-8p      DX      DX Rm 1
## 5                12a-8a   EC DX DX Rm 5 (EC)
## 6                12a-8a      DX  DX Portable
dat<- dat[dat$Ordered.to.Complete...Mins >= 0,]

Part 1

Patients that are age 65 or older qualify for Medicare. We are creating a histogram of the time required to complete X-Ray orders for Medicare patients. The allowable range of times is restricted between the first and third quartile.

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
q1 = quantile(medicare$Ordered.to.Complete...Mins, 0.25)
q3 = quantile(medicare$Ordered.to.Complete...Mins, 0.75)
medicare.iqr = medicare[medicare$Ordered.to.Complete...Mins >= q1 & medicare$Ordered.to.Complete...Mins <= q3,]
hist(medicare.iqr$Ordered.to.Complete...Mins, breaks = 25, main = "X-ray Completion Times for Medicare Patients", xlab = "Completion Time in Minutes", ylab = "Number of Observations", col = "red",border = "black")

This applies the filter to the data to get patients aged 65 or older. It then restricts the completion times to the IQR range, which is from the first quartile to the third quartile. The histogram is right-skewed because most X-ray orders were completed in the lower time range, while fewer orders took longer.

Part 2

We are comparing Radiology Technician 62 and Radiology Technician 65 based on the median time to complete an X-ray order.

t62 = dat[dat$Radiology.Technician == 62,]
t65 = dat[dat$Radiology.Technician == 65,]
summary(t62$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(t65$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     1.0    16.0    27.0    94.9    45.0 35306.0
median62 = median(t62$Ordered.to.Complete...Mins)
median65 = median(t65$Ordered.to.Complete...Mins)
cat("Radiology Technician 62's median completion time:", median62,"\nRadiology Technician 65's median completion time:", median65)
## Radiology Technician 62's median completion time: 80 
## Radiology Technician 65's median completion time: 27

It means Technician 62 had a median completion time of 80 minutes, while that of Technician 65 was 27 minutes. It, therefore, means that Technician 65 is faster based on the median completion time.

Part 3

Create a side by side boxplot comparing the ages of patients who receive STAT and Routine orders for an X-ray.

STAT <- dat[dat$Priority == "STAT",]
Routine <- dat[dat$Priority == "Routine",]
boxplot(Routine$PatientAge, STAT$PatientAge, names = c("Routine", "STAT"), main = "Patient Age by X-Ray Order Priority", xlab = "Order Priority",ylab = "Age in Years",col = c("red", "black"))

The boxplot should show that Routine orders have a higher median patient age than STAT orders. The spread is wider for STAT orders, which means patient ages vary more for STAT orders. There are also some younger patients shown as low outliers.

Part 4

We are calculating the mean and standard deviation of the time required to complete an X-Ray order on floor 3W compared to floor 4W.

f3W = dat[dat$Loc.At.Exam.Complete == "3W",]
f4W = dat[dat$Loc.At.Exam.Complete == "4W",]
summary(f3W$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     2.0    38.0    70.0  1463.1   402.5 29637.0
summary(f4W$Ordered.to.Complete...Mins)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##     1.00    31.75    58.00  1675.45   610.75 37572.00
mean3W = mean(f3W$Ordered.to.Complete...Mins)
mean3W
## [1] 1463.051
sd3W = sd(f3W$Ordered.to.Complete...Mins)
sd3W
## [1] 3894.639
mean4W = mean(f4W$Ordered.to.Complete...Mins)
mean4W
## [1] 1675.451
sd4W = sd(f4W$Ordered.to.Complete...Mins)
sd4W
## [1] 4387.644