Follow the below steps:
1. Install R in your system. Visit below for installing R.
2. Then Go to Power BI -> Options &Settings -> Options - > Preview features - >Tick mark for R option.
If R scripting is already enabled then you can see the default location in the path folder of R in R Scripting Options
3. Now Click on R script in Power BI visualisation tab on right side of the screen.
4. Click on R to run R script in Power BI.