I am trying to read into R Excel spreadsheets that include time-entry rows grouped by employee, which look like this when the groups are collapsed (the commas are used here to delimit columns):
Column A Column B
Alice
2015-01-01 8
2015-01-02 7.5
2015-01-03 6
Bob
2015-01-02 6
2015-01-03 8
I am able to read the spreadsheets into data frames using the xlsx::read.xlsx2
function, but I have been unable to figure out how to convert the subtotal rows into a column, so that the data frame looks like this:
Alice 2015-01-01 8
Alice 2015-01-02 7.5
Alice 2015-01-03 6
Bob 2015-01-02 6
Bob 2015-01-03 8
I tried looking at reshape
and dplyr
, but I couldn't figure out if they could help. Can someone please point me in the right direction?