Common effect of chemical and external pressures on the magnetic properties of RCoPO (R = La, Pr)