Sean.Kennedy
Sean.Kennedy

Reputation: 11

Visualizing a staffing schedules in R

First time poster here, so please forgive any faux pas on my part.

I have a set of data which consists of essentially 3 fields:

1)Position 2)Start_of_shift (datetime object) 3)End_of_Shift (datetime object)

From the datetime object I can extract date, day of week, & time. The schedules are 24/7 and do not conform to any standard 3 shift etc. rotation, they are fairly specific to a site. (I am using the lubridate package)

I would like to visualize Time of day vs. Day of Week to show numbers of staff, so that I can see heavy concentrations of staff and where I am light at specific days and times.

I am unsure on how to approach this problem as I am relatively new to R and I have found the various date time packages & base utilities confusing and often conflicting with each other. While I find plenty of examples of time series plotting, I have found next to nothing on how to plot if you have a start and end time in separate fields and want to show areas of overlap

I was thinking of using ggplot2 with geom_tile to plot this out, with a smoother, but wanted to know if there were any good examples out there that do something similar or if anyone has any idea on how I should transform my data to best achieve my end objective. I wanted to keep the time continuous but as a last resort I will discretize it into 15 minute chunks if necessary, but didn't know if there were other options?

Any thoughts?

Upvotes: 1

Views: 1439

Answers (3)

AndrewMinCH
AndrewMinCH

Reputation: 720

To work out how many people are present (or should be if it's a future event) you need to think of your staffing as a stock / flow.

First step would be to use the melt function in package reshape2 to get all the dates in one column and the event (starting / finishing) in another.

From this you can create a running total of how many people will be in at any time.

Upvotes: 0

Bryan Hanson
Bryan Hanson

Reputation: 6213

Maybe the timeline package is what you need. I've found it very good for planning projects. It's on CRAN, but you can see a quick example at it's Github home here.

Upvotes: 3

Greg Snow
Greg Snow

Reputation: 49640

You might consider using a gannt chart, the gannt.chart function in the plotrix package is one option for creating them.

Upvotes: 3

Related Questions