Consider 𝑂2 or 𝑁2. Then there should be 𝑓=5. And the derivation is
by a factor different. Can we still use the law as an approximation?
Yes.
The so called kinetic temperature of an ideal gas, as normally measured, is based on 3 degrees of freedom and does not (and need not) account for molecular rotation (and vibration). These additional forms of kinetic energy are important when determining the specific heats of ideal gases and the total internal energy of an ideal gas.
For an ideal gas, any process, the change in internal energy is given by
$$\Delta U=nC_{V}\Delta T$$
The specific heat at constant volume, and therefore the internal energy, depends on the number of degrees of freedom $f$ according to
$$C_{V}=\frac{f}{2}$$
$$U=\frac{fnRT}{2}$$
So for the monatomic gas, $C_{V}=\frac{3}{2}R$ and for the diatomic oxygen and nitrogen gases $C_{V}=\frac{5}{2}R$. Consequently the additional degrees of freedom are accounted for in the case of gases other than monatomic gases.
That being said, any gas can be considered to approach ideal gas behavior as long as all collisions between gas particles, and between the particles and the walls of a container, can be considered perfectly elastic (lose no kinetic energy) and in which there are no intermolecular attractive forces so that the total internal energy can be considered purely kinetic. The latter requirement is met for gases having combinations of higher temperatures and lower pressures so that the gas particles are far enough apart that intermolecular attraction forces can be ignored.
Thus, $N_2$ and $O_2$ at, for example, room temperature and atmospheric pressure, can be considered to exhibit behavior approaching that of an ideal gas.
Hope this helps.