Purpose of Resistor - comparator
One of the things it might be doing is reverse biasing the diode when SW1 is open, pulling it below cap voltage.  This would reduce the likelyhood of stray fields forward biasing the diode and charging the (peak detector) cap, as long as 4.7k was strong enough to drain off the field charge and maintain reverse bias.