Hello,
For the avarage power over multiples of periods, yes you are right (your calculation also). There is a big however: The resistor ""feels" the avarage power/temperature only when the thermal time constant is large with respect to the pulse duration.
You can compare this with the time constant of an RC circuit, when the frequency is well above the -3 dB bandwidth, the output is the avarge voltage. When the frequency is too low, the voltage will swing above and below the average value.
With the resistor it is the same, when the time constant is not large enough, the temperature of the resistor will swing above and below the avarage temperature.
The pulse power handling of resistors is limited because of maximum operating temperature of the materials, but also because of too large temperature gradients in the material that may result in cracks.
But don't worry, when you are talking about 20W resistors and 20 kHz, the resistor will not notice any difference between 20W DC power, or 20W average because of a 40W with 50% duty cycle (at 20 kHz)