Engine Pinging on 1993 Subaru Loyale

Frequent/extreme engine pinging during acceleration; recent cross-country trip suggests rich fuel/air mixture because the pinging went away at higher altitudes (pinging gone above 6000 feet). Should I just replace the O2 sensor? Or could it also be the injectors or ECM?

Asked by for the 1993 Subaru Loyale