As question, I have found something similar here, but how to do it in R?
You are looking for a confidence interval around the count from a Poisson process. If you put for example 42 into your linked example you get
You can get this in R using
and similarly the other values by changing
If the number of event is too small, it would be better to use the exact method.
Reference: Liddell FD. Simple exact analysis of the standardised mortality ratio. J Epidemiol Community Health. 1984;38:85-8.