I have my database from the hflights
package of R, which shows a number of flights in the US. I need to calculate the average distance traveled ( Distance
) for each day of the week (variable DayofWeek
) between flights with a delay of more than 60 and between those with a delay of less than 60 (variable% with%). You must use a single DepDelay
.
I've tried something like this, but it's wrong:
y=(c(which(sapply(dados,is.numeric))))y
apply(as.matrix(y),1,function(x){tapply(dados[,x],list(dados$DayofWeek,dados$DepDelay>60),mean)})