\[pV=nRT\]
Rearrange this equation to give
\[R=\frac{pV}{nT}\]
1 mol of gas at stp (standard temperature and pressure) occupies 22400 cm3.
The standard temperature is 0 ° C or 273.15 ° K and the standard pressure is 101.3 kPa.
Then
\[R= \frac{101.3 \times 22400 \times 10^{-6|}}{1 \times 273.15} = 8.31 J mol^{-1} K^{-1}\]