In order to run R and R-studio on your system, you need to follow the following three steps in the same order.
Follow the steps below with respect to the operating system you are using:
Download the binary setup file for R from the following link. R for Windows. Open the downloaded .exe file and Install R.
Download the appropriate version of .pkg file form the following link. R for Mac. Open the downloaded .pkg file and Install R.
For complete R System installation in Ubuntu,
sudo apt-get install r-base
On the following link Download R Studio choose the appropriate installer file for your operating system, download it and then run it to install R-studio.
If your need to use R requires a particular package/library to be installed in R-studio. You can follow the instructions below to do so.