dat2<-read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_IMSE.csv")
head(dat2)
##   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
summary(dat2$Ordered.to.Complete...Mins)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    -196      18      33    1644      67  112168
?hist
## starting httpd help server ... done
hist(dat2$Ordered.to.Complete...Mins)

hist(dat2$Ordered.to.Complete...Mins,breaks = 10)

hist(dat2$Ordered.to.Complete...Mins,main = "histogram of Ordered.to.Complete...Mins",xlab ="Ordered.to.Complete...Mins",ylab = "frequency",col = "aquamarine")

q1 <- quantile(dat2$Ordered.to.Complete...Mins, 0.25, na.rm = TRUE)
q3 <- quantile(dat2$Ordered.to.Complete...Mins, 0.75, na.rm = TRUE)


iqr_data <- subset(dat2, Ordered.to.Complete...Mins >= q1 & Ordered.to.Complete...Mins <= q3)
hist(iqr_data$Ordered.to.Complete...Mins,
     breaks = 10,
     main = "Histogram of X-Ray Completion Time (IQR, Age 65+)",
     xlab = "Completion Time (Minutes)",
     ylab = "Frequency",
     col = "aquamarine")

#The histogram is right-skewed, indicating that while most X-ray orders for Medicare patients are completed in a shorter amount of time

library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
median_times <- dat2 %>%
  filter(Radiology.Technician %in% c(62, 63, 64, 65)) %>%
  group_by(Radiology.Technician) %>%
  summarise(median_time = median(Ordered.to.Complete...Mins, na.rm = TRUE))

print(median_times)
## # A tibble: 4 × 2
##   Radiology.Technician median_time
##                  <int>       <int>
## 1                   62          80
## 2                   63          18
## 3                   64          82
## 4                   65          27

#Overall, technician 64 shows the best median speed, while technician 65 might need to improve efficiency.

boxplot(PatientAge ~ Priority,
        data = dat2,
        main = "Patient Age by Order Priority (STAT vs Routine)",
        xlab = "Order Priority",
        ylab = "Patient Age",
        col = c("pink", "skyblue"))

#Each boxplot represents the distribution of patient ages for each priority group (STAT and Routine).The box shows the interquartile range (IQR), the middle 50% of patient ages. The line inside the box is the median age. The whiskers show the approximate range of ages

library(dplyr)

stats_by_floor <- dat2 %>%
  filter(Loc.At.Exam.Complete %in% c("3W", "4W")) %>%
  group_by(Loc.At.Exam.Complete) %>%
  summarise(
    mean_time = mean(Ordered.to.Complete...Mins, na.rm = TRUE),
    sd_time = sd(Ordered.to.Complete...Mins, na.rm = TRUE),
    count = n()
  )

print(stats_by_floor)
## # A tibble: 2 × 4
##   Loc.At.Exam.Complete mean_time sd_time count
##   <chr>                    <dbl>   <dbl> <int>
## 1 3W                       1463.   3895.   952
## 2 4W                       1675.   4388.   668

#X-Ray orders on 3W are completed faster and with more consistency compared to 4W, indicating better efficiency on 3W.