I'm sure this question will seem a little bit basic for many but here is my problem:
I want to create a new variable which is an equation of other variables in RStudio:
D$satisfaction.conditions <- (D$imp.distance * D$sat.distance
+ D$imp.salaire * D$sat.salaire
+ D$imp.horaires * D$sat.horaires
+ D$imp.chargetravail * D$sat.chargetravail
+ D$imp.nbservice * D$sat.nbservice
+ D$imp.locaux * D$sat.locaux
+ D$imp.equipements * D$sat.equipements
+ D$imp.ambiance * D$sat.ambiance
+ D$imp.relationcollegues * D$sat.relationcollegues
+ D$imp.stress * D$sat.stress)
The issue is that I have some missing values in the equation, so I get a NA result for some observations.
I know that there is something to do with na.rm=TRUE but I can't find where to put it. I tried at the end but I get a
Error: unexpected symbol in:
" + D$imp.relationcollegues * D$sat.relationcollegues
+ D$imp.stress * D$sat.stress) na.rm"
How can I get my new variable {satisfaction.conditions} ommiting NA values ?