1 Load Packages

library(readxl)

2 Introduction

Care One Hospital is a mid-size (approximately 350 bed) teaching hospital that is connected with a medical school at a major university.  It has been a recognized leader in providing quality care and recently achieved magnet status.  Care One Hospital is a not for profit county hospital, providing care to anyone in need regardless of their ability to pay.  They have an emergency room connected with their hospital, several floors for general inpatient care, and several departments of specialty care.

The administrators at Care One hospital have recently become concerned about the uptick in the length of stay of patients at their hospital.  After doing a bit of investigation into this problem, several providers at Care One Hospital have noted that the time taken to receive an ordered X-Ray is excessively long.  Care One Hospital has pulled 5 months of data from the years 2016-2017.  The data has been de-identified, that is patients, providers, and radiology technicians have been assigned a unique identification number. 

3 Data Preparation

First, we will read in the raw data

df <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_CareOne.csv")
head(df)
##   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 In.Rad.Room Ordering.Physician
## 1 DX Abdomen 2 vw w/single chest           1                  4
## 2 DX Abdomen 2 vw w/single chest           1                  4
## 3 DX Abdomen 2 vw w/single chest           1                150
## 4 DX Abdomen 2 vw w/single chest           1                130
## 5 DX Abdomen 2 vw w/single chest           1                173
## 6 DX Abdomen 2 vw w/single chest           1                349
##   PatientTypeMnemonic Encounter.Type Priority  OrderDateTime
## 1                  IP      Inpatient  Routine 12/27/16 10:32
## 2                  IP      Inpatient  Routine  1/13/17 11:44
## 3                  IP      Inpatient  Routine   1/2/17 17:19
## 4                  IP      Inpatient  Routine 11/13/16 10:13
## 5                  IP      Inpatient     STAT  12/13/16 3:22
## 6                  IP      Inpatient  Routine   1/17/17 5:38
##   ExamCompleteDateTime  FinalDateTime Loc.At.Exam.Complete
## 1       12/27/16 11:19 12/28/16 14:32                  GTU
## 2        1/13/17 12:32  1/14/17 16:00                  GTU
## 3         1/2/17 18:00    1/3/17 7:44                   3W
## 4        11/14/16 9:34 11/14/16 16:40                   4W
## 5        12/13/16 4:04  12/13/16 3:19        Emergency Ctr
## 6         1/17/17 7:47  1/17/17 10:55                   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

We would like to keep only the columns with the patient age and priority

df2 <- df[,c(2,9)]
head(df2)
##   PatientAge Priority
## 1         75  Routine
## 2         87  Routine
## 3         35  Routine
## 4         51  Routine
## 5         67     STAT
## 6         54  Routine

Now we will change the variable types to be a number and a factor

df2$Priority <- as.factor(df2$Priority)
str(df2)
## 'data.frame':    43631 obs. of  2 variables:
##  $ PatientAge: int  75 87 35 51 67 54 34 65 67 40 ...
##  $ Priority  : Factor w/ 2 levels "Routine","STAT": 1 1 1 1 2 1 1 1 1 1 ...

4 Basic Descriptive Statistics

Let’s look at some basic descriptive statistics for each variable.

4.1 Patient Age

Here are some summary statistics for Patient Age.

summary(df2$PatientAge)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0    33.0    53.0    50.5    67.0   102.0

Here’s a boxplot of Patient Age

boxplot(df2$PatientAge)

4.2 Patient Priority

5 Complete R Code

df <- read.csv("https://raw.githubusercontent.com/tmatis12/datafiles/refs/heads/main/RadDat_CareOne.csv")
head(df)
df2 <- df[,c(2,9)]
head(df2)
df2$Priority <- as.factor(df2$Priority)
str(df2)
summary(df2$PatientAge)
boxplot(df2$PatientAge)