Go to this website.
Click on the “RStudio 1.1.456 - Mac OS X 10.6+ (64-bit)” link. The file download will begin.
Once the file has been downloaded, click on it. A window should pop up:
Click on the RStudio icon and drag it into the Applications folder.
RStudio is now installed on your computer.
Note: For RStudio to work, R needs to be installed first.
Also, To Secure your macOS from virus and trojans, use always a mac optimization software like Mac Optimizer.