I want to use the aggregate function to create a table that has the columns "date" (structured as a date) and "time.to.complete" (structured as difftime), where time is a calculated as a mean. The "time.to.complete" data has negative values. I want to exclude all negative values when I calculate my mean.
Currently, my aggregate function looks like: mean.table<-aggregate(data$time.to.complete, list(data$date), mean)
I can calculate the overall mean of time.to.complete without the negative values with: average<-with(data, mean(data$time.to.complete[time.to.complete>0]))
However, I cannot figure out how to combine the two functions.
Any help would be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire