Bonjour à tous,
J'ai un data.frame :
Et je souhaiterais sélectionner les lignes pour lesquelles la valeur absolue de la moyenne des valeurs 1dpe - moyenne valeurs 2dpe > 2 ET la variance 1dpe < à la variance des moyennes (var(c(mean(1dpe),mean(2dpe)) ET la variance 2dpe < à la variance des moyennesCode:
1
2
3
4
5
6
7 > test 1dpe 1dpe 2dpe 2dpe a 18.602971 3.630571 3.410561 4.352493 b 14.602971 14.925448 3.410561 3.591148 c 4.352493 4.326872 12.844528 12.658118 d 3.564454 14.925448 14.602971 3.591148 e 3.564454 3.630571 13.190097 12.499158
pour cela, j'ai écrit cette requête :
mais lorsque je fais :Code:
1
2
3
4
5
6
7 idx_1vs2 <- test[ abs((apply(test[,c(grep("1dpe",colnames(test)))],1,mean) - apply(test[,c(grep("2dpe",colnames(test)))],1,mean)))>2 && 2*apply(test[,c(grep("1dpe",colnames(test)))],1,var)- apply(data.frame(apply(test[,c(grep("1dpe",colnames(test)))],1,mean),apply(test[,c(grep("2dpe",colnames(test)))],1,mean)),1,var)<0 && (2*apply(test[,c(grep("2dpe",colnames(test)))],1,var)-apply(data.frame(apply(test[,c(grep("1dpe",colnames(test)))],1,mean),apply(test[,c(grep("2dpe",colnames(test)))],1,mean)),1,var))<0 ,]
objet <- test[idx_1vs2 ,] je n'ai aucune ligne, alors que je devrais avoir les lignes 2,3,5 qui "remplissent" les trois conditions .
Quelqu'un pourrait me dire ce qui ne va pas ?
Merci d'avance,
Isa