How to use the law of universal gravitation to deduce the formula of celestial body density

How to use the law of universal gravitation to deduce the formula of celestial body density

The law of gravitation is (GMM) / (R ^ 2) = mg, (GM) = (GR ^ 2), M = 4 / 3 π R ^ 3 times density, so (4 / 3 π GR ^ 3 times density) / R ^ 2 = G
So the density is (3G) / (4 π RG)