Bonjour,

je souhaiterais créer une nouvelle variable avec des données "corrigées".

Je pensais passer par un mutate / case when mais je bute dans la deuxième partie de l'expression après le tilde.
Je ne sais que lui indiquer du texte et pas une formule.

En fait je cherche à transposer en R quelque chose qui s'écrit comme ça en SAS

Code SAS : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
fl_intcorr=fl_int;  /** pour la plupart des IRIS  **/
if class7=1 and tx_rep_int<45.6 then fl_intcorr=0.506*(fl_pap+flne_x+FL_int);      
if class7=2 and tx_rep_int<47 then fl_intcorr=0.52*(fl_pap+flne_x+FL_int);
if class7=5 and tx_rep_int<11.3 then fl_intcorr=0.163*(fl_pap+flne_x+FL_int);
if class7=7 and tx_rep_int<11.1 then fl_intcorr=0.161*(fl_pap+flne_x+FL_int);
if class7=3 and tx_rep_int<33.5 then fl_intcorr=0.385*(fl_pap+flne_x+FL_int);
if class7=4 and tx_rep_int<31.3 then fl_intcorr=0.363*(fl_pap+flne_x+FL_int);
if class7=6 and tx_rep_int<34.8 then fl_intcorr=0.398*(fl_pap+flne_x+FL_int);
 
fl_papcorr=fl_pap+FL_int-fl_intcorr; /* pour tous les IRIS **/


moi je suis partie sur un truc du genre

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
TEST3 <- TEST3 %>% mutate (FL_INT_CORR = 
                          case_when (
 CLASS7=1 &  TX_REP_INT < 45.6 ~ 0.506*(TEST3$FL_PAP+TEST3$FLNE.x+TEST3$FL_INT)
))
Mais ce qui est écrit après le tilde ne marche pas

une idée?

merci