For a data frame populated from a SQL query which looks like this:
Company Month Total_Count
ABC 2012-03 10
ABC 2009-01 1
DEF 2011-01 29
GHI 2001-09 10
GHI 2008-01 9
GHI 2010-09 100
I would like to come up with a summary report that would output this:
Company Total Months
ABC 11 10 1
DEF 29 29
GHI 119 10 9 100
where column Total
would be the sum across all the months
and column Months
would be the individual counts for each month encountered for that org. I would love to see if it is possible to somehow squeeze in the actual Month also. Something like:
Company Total Months
2009-01 2012-03
ABC 11 10 1
2011-01
DEF 29 29
2001-09 2008-01 2010-09
GHI 119 10 9 100
So far, I have only been able to get the first 2 columns of the desired result above by doing:
df1 <- ddply(resultSet, .(company_name), summarize, sum(as.numeric(total_count)))
But I am not sure how I can append information for individual months