I need to get a chart which shows the mean resolution time for a bunch of support requests. I got a data frame with all the requests, every line is a different request, and each column represents a different field like month, priority, group, resolution time and so on...
From that table I would like to get the mean resolution time for every month. I have been trying different ways but I haven't been able so far. I think I am very close right now. This is my code:
df_tresolucion <- setNames(aggregate(tabla_tiempos$Ticket,by=list(tabla_tiempos$Metrica),FUN = rowMeans(tabla_tiempos[,10,drop=FALSE])),c("Metrica","Promedio"))
tabla_tiempos is the data frame I have mentioned before containing all the support requests:
Ticket <- c('119237','119239','120598','120600','120612', '120615')
Metrica <- c('apr 2017','may 2017', 'may 2017','may 2017','jun 2017','jun 2017')
Pais <- c('ESP','ESP','ESP','ESP','ESP','ESP')Estado <- c('Closed', 'Closed', 'Closed', 'Closed', 'Closed', 'Closed')
Escalado <- c('CEDEX', 'CEDEX', 'TAC','CEDEX','CEDEX','TAC')
Vendor <- c('Cisco','Cisco','Cisco','Juniper','Cisco','Cisco')
Familia <- c('C7600','C7600','MX960','C7600','C7600','MX960')
Severidad <- c('Minor','Minor','Major','Minor','Minor','Major')
SLA <- c('Dentro de SLA','Dentro de SLA','Dentro de SLA','Dentro de SLA','Dentro de SLA','Dentro de SLA')
tresolucion <- c ('1.73','2.30','26.97','1.73','2.30','26.97')
tabla_tiempos <- data.frame(Ticket,Metrica,Pais,Estado,Vendor,Familia,Severidad,SLA,tresolucion)
$Ticket is a unique field for each request and $Metrica represent the month where the request was opened.The 10th column in the data frame tabla_tiempos contains the resolution time. I used the parameter DROP = FALSE to keep the dimensions so that I can apply the function RowMeans.
Unfortunately I am getting this error which I don't really understand what means:
Warning: Error in match.fun: 'rowMeans(tabla_tiempos[, 10, drop = FALSE])' is not a function, character or symbol
So as I said before I would like to aggregate by month and calculate the mean resolution time for every month and later to create another data frame (this would be df_tresolucion)containing all this information: 2 columns (month and mean time) and one row for each month.
Does anybody know how I could do this? Thanks in advance!