R in Eighty Days

How much R can I learn from scratch in eleven-and-a-half weeks?

Day 4: Sunday 18th August 2019

I said on Day One that I would set out some of the specific things I want to be able to do with R by the time I get to Day Eighty. Here's one of the things. I'll get to the complete picture later on, but I've been doing a piece of work recently that has been about measuring and describing inpatient clinical activity in a way that is—hopefully—relevant and meaningful to clinicians. The clinicians in question are physicians: consultants in Medicine of the Elderly.

The work began inauspiciously. The clinical director had been pretty dismissive about some activity data that had been tabled in a meeting I was at. The meeting was specifically about length of stay in Medicine of the Elderly and her view was that if the way that length of stay was measured was wrong, then we would never get any buy-in from the doctors if we wanted to try and reduce the length of stay. The key point in all of this was that we weren't counting stays properly and we weren't measuring the length of those stays properly, either.

The way I tried to set about resolving this problem was by meeting separately with a small group of clinicians in front of a screen, and we'd look at the patient-level data line by line. I used an Oracle view where each row in the table represented the time an inpatient spent in a unique ward/specialty/consultant combination. In other wards, a new row was generated every time one of those three things changed. Then I organised the data in Excel so that each patient's episodes and stays were organised chronologically and sequentially. This allowed the clinicians to look at each patient journey, point at individual rows in Excel on the screen and say things like: "No, don't include that row, don't include that row either, start with that one, include that one, include that one, don't include that one, so yes, right, yes, the patient was effectively discharged from our care at that point."

It took more than one meeting. And we went through quite a few sets of patients this way (I chose recent patients, so that there was a chance the clinicians might remember some of the individual patients) until eventually an algorithm emerged from the discussions. The stays started as soon as the patient left the Acute Medical Unit (AMU) (all of the time in the AMU was excluded, even when the patient had been transferred to the care of a geriatrician whilst they were still in the AMU), and the stay ended when the patient left the hospital or the specialty of Medicine of the Elderly.

So to arrive at this 'algorithm', I was basically using a mash-up of SQL and Excel. And one of my objectives with R in Eighty Days is to see if I can replace that set of tasks by just using R. There are quite a few other things I want to do. Things that are more to do with how the data gets visualized, but for the moment, there's this data prep thing that I want to see if I can do in R.

Previous Day ... Next Day