I want to clear up a few things here where I think are people talking at cross purposes.
As stated above, the I register holds the most significant 8 bits of a jump vector, while the lowest 8 bits are supplied on the data bus when IM2 is enabled. However, on a standard ZX Spectrum, this is unused, and hence you will get an undefined value. However, IM2 is useful as it fires every screen refresh at a consistent interval (1/50 second), so it's ideal for logging time or some other background task, such as music.
The workaround for this is to supply a 257 byte table where every byte is the same, so when an IM2 interrupt is triggered, going to any random place in the table will give a consistent result. A full explanation is at http://www.breakintoprogram.co.uk/hardware/computers/zx-spectrum/interrupts, and one of many, many, many implementations of this is at https://ritchie333.github.io/monty/asm/50944.html
The R register is only really used internally for the DRAM refresh, but it can be programmed. One of its two main uses on the ZX Spectrum was to generate a random number (although there are other ways of doing this, such as multiplying by a largish number and taking the modulus of a large prime, which is what the Spectrum ROM does - https://skoolkid.github.io/rom/asm/25F8.html#2625). The other use was to produce a time based encryption vector, that was hard to crack as stopping for any debug would change the expected value of R and produce the wrong encryption key for the next byte. Quite common on old tape protection systems such as Speedlock.