Hi,
Welcome to the RStudio community!
We're happy to help you with issues you are have working on code, but it's not really the purpose of this forum to just do all the work for you for free
If you're new to R, I suggest you search the web for tons of great tutorials on how to get started with R (there are even entire interactive courses you can take). Once you got started, you can start trying to convert the stata code given here (I assume you know this one a bit) and see how far you get. Once you get stuck, we're happy to help you out if you can create a reprex.
A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:
Good luck,
PJ