Open In App

Power BI – Create a R Script Visual

An R script is different from R visuals. It helps transform our data into statistical analysis and machine learning algorithms on our datasets. It creates beautiful charts, with statistical measures. To make R Script Visual, we need to have some prerequisites i.e. Installing R in the System, and Checking the Path of R in Power BI. In this article, we will learn how to create an R Script Visual in Power BI. 

Installing R In the System 

Before creating an R visual in Power BI, we first need to install R into our system. 



The following are the steps: 

Step 1: To download R on your PC. Go to this link. On the top of the website, we will find an option, name, Download R-4.2.1 for Windows. An exe name, R-4.2.1-win.exe will be downloaded. 

 

Step 2: Double-click on the exe downloaded. The installation page will open. Select the language as English, and click on the Ok button. 



 

Step 3: The Setup page for R is opened. Read the agreement, and click on the Next button. 

 

Step 4: Now, select the path at which we want to install the R. It is preferred to install at the default location. For example, C:\Program Files\R\R-4.2.1.  Click on the Next button. 

 

Step 5: Now, we need to select the components, which we want to install while setting up R. Check all three boxes i.e. Main Files, 64-bit Files, and Message translations.  Click on the Next button. 

 

Step 6: If we want to customize the startup options, then click on Yes, else No. By default, it is set to No. Click on the Next option. 

 

Step 8: Check the boxes, for which you want to add additional shortcuts. Click on the Next button. 

 

Step 9: The installation will start. Wait until the installation is finished. 

 

Step 10: The installation is completed. Click on the Finish button. The R has successfully been installed into the system. 

 

Check For Path Setup Of R In Power BI 

After the successful installation of R in Power BI. Our next task is to check whether the Power BI, has successfully taken the path of the R or not. 

The following are the steps: 

Step 1: Open Power BI. Click on the File option.

 

Step 2: A list will appear on the left side of the screen. Click on Options and settings. Then click on the Options button. 

 

Step 3: A new dialogue box name, Options will appear. Under the Global section, click on the R scripting option. Then under Detected R home directories, check whether the installation path of R existed in it or not. If the path is not present, then copy the R installation path, and paste it under the Home directories column. For example, C:\Program Files\R\R-4.2.1

 

Creating an R script Visual In Power BI 

Now, we are ready to create an R script Visual. For example, we are given a dataset Employee, and we want to create statistical charts, with R script. 

The following are the steps: 

Step 1: Given a dataset, it contains 11 columns, which can be viewed in the image below. 

 

Step 2: Under the Visualizations section, click on the R script visual option. 

 

Step 3: By default, R script visuals are not enabled in Power BI. Click on the Select to enable option. 

 

Step 4: A new dialogue box name, Enable script visuals will appear. Click on the enable button. 

 

Step 5: An empty R script will appear. Drag and drop the columns, we want to put into a data frame. For example, Employee Name, Maximum Projects, Projects Completed, and Targeted Projects. 

 

Step 6: At the bottom of the Power BI screen, a R script editor will appear. By default, a R script editor creates a dataframe for the columns added under Values section of Power BI. So, there is no need to create a dataframe manually. 

 

Step 7: Now, add the required R script. Generally, psych is a library in R, which helps us create effective statistical visualizations for the data added. Write the code as show in the image below, to acquire psych library. Then type, pairs.panels(dataset) to make charts for the columns added. 

 

Step 8: A R script Visual is successfully created in Power BI. 

 


Article Tags :