Arduino nano input of analog pin is always 1

I stand corrected.
I ran a little test myself, and (R == HIGH) evaluates to 1 only when R is 1, and 0, 2, 3, … 1023 all produce a 0.
Apparently “HIGH” is translated to 1 before the comparison, the compiler doesn’t recognize it as Boolean.
Still, it doesn't produce the result the OP probably hoped for.