I have data in a .csv file showing enquiries received by different teams on different dates. Enquiries are entered as follows:
Team,Date_received,Date_answered
Team 1,31/01/10,05/02/10
Team 3,05/03/10,17/04/10
...
I want to plot a graph showing how many enquiries each team received over each of the last six months but I’m new to R and getting nowhere fast. I’ve looked up time series documentation (in O’Reilly’s R in a Nutshell) but it seems to be much more complex than what I need.
So far I’ve read in the data and converted the date strings into POSIXlt as follows:
c_data <- read.table("~/data.csv", header=T, sep=",")
c_data$Date_received <- as.Date(c_data$Date_received, "%d/%m/%y")
c_data <- as.POSIXlt(c_data$Date_received)
...
but from there I’m lost. What I want to do is extract the month from the POSIXlt field, count the incidence of each ‘Team’ string in each month and plot them against each other, but I don’t know which functions handle those things and I’m struggling with the docs.
I know I’m at early stages here so even just a pointer to the function I should be reading about would be appreciated.
Starting with some dummy data:
First you have to declare your dates as Date objects.
To extract the month, nothing simpler:
And then, to find the incidence of each team per month, you just have to tabulate according to your teams and months:
And now as a data.frame (for plotting purposes):