This report presents a descriptive analysis of X-ray order times from a major US hospital, focusing on specific questions.
#get data from URL
data <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_IMSE.csv")
#filter out rows with negative values
data <- data[data$Ordered.to.Complete...Mins >= 0, ]
#question 1
#filter Medicare patients (age 65 or older)
medicare_data <- data[data$PatientAge >= 65, ]
#calc IQR for the time to complete an order
Q1 <- quantile(medicare_data$Ordered.to.Complete...Mins, 0.25)
Q3 <- quantile(medicare_data$Ordered.to.Complete...Mins, 0.75)
#restrict data to within IQR range
medicare_data <- medicare_data[medicare_data$Ordered.to.Complete...Mins >= Q1 & medicare_data$Ordered.to.Complete...Mins <= Q3, ]
#create histogram
hist(medicare_data$Ordered.to.Complete...Mins,breaks = 10,
main = "Histogram of Time to Fulfill X-ray Orders for Medicare Patients",
xlab = "Time to Complete Order (Mins)")
#question 2
#filter data for Technicians 62 and 65
tech_62 <- data[data$Radiology.Technician == 62, "Ordered.to.Complete...Mins"]
tech_65 <- data[data$Radiology.Technician == 65, "Ordered.to.Complete...Mins"]
#calculate median times
median_62 <- median(tech_62)
median_65 <- median(tech_65)
print("Median time for Technician 62:")
## [1] "Median time for Technician 62:"
median_62
## [1] 80
print("Median time for Technician 65:")
## [1] "Median time for Technician 65:"
median_65
## [1] 27
#question 3
# extract patient ages for STAT and Routine orders
ages_STAT <- data[data$Priority == "STAT", "PatientAge"]
ages_Routine <- data[data$Priority == "Routine", "PatientAge"]
#combine into a list for boxplot
boxplot_data <- list(STAT = ages_STAT, Routine = ages_Routine)
#create boxplot
boxplot(
boxplot_data,
main = "Age of Patients Receiving STAT vs Routine Orders",
ylab = "Patient Age")
#question 4
# filter times for floors 3W and 4W
time_3W <- data[data$Loc.At.Exam.Complete == "3W", "Ordered.to.Complete...Mins"]
time_4W <- data[data$Loc.At.Exam.Complete == "4W", "Ordered.to.Complete...Mins"]
#calculate mean and standard deviation for each floor
mean_3W <- mean(time_3W)
sd_3W <- sd(time_3W)
mean_4W <- mean(time_4W)
sd_4W <- sd(time_4W)
print("Floor 3W - Mean:")
## [1] "Floor 3W - Mean:"
mean_3W
## [1] 1463.051
print("Floor 3W - Standard Deviation:")
## [1] "Floor 3W - Standard Deviation:"
sd_3W
## [1] 3894.639
print("Floor 4W - Mean:")
## [1] "Floor 4W - Mean:"
mean_4W
## [1] 1675.451
print("Floor 4W - Standard Deviation:")
## [1] "Floor 4W - Standard Deviation:"
sd_4W
## [1] 4387.644