I am trying to create an "if... then" statement in R in which two variables, G1 and G2, lie within a range of values in a given dataset. For example, if (200 > G1 > -100) and (200 > G2 > -100), then G = mean(G1,G2)
My code looks like this:
if(200 > G1 > -100 & 200 > G2 > -100) {G = mean(G1,G2)}
The error I'm getting reads: Error: unexpected '>' in " if(200 > G1 >"
Any help would be much appreciated! Thanks
Aucun commentaire:
Enregistrer un commentaire