Anybody can use R visuals in Power BI

ByHariharan Rajendran

Anybody can use R visuals in Power BI

This post explains that anyone can get R visuals for their data with ggplot2.

Power BI is very famous for different types of visualizations right from out of the box visualizations, R visualizations and custom visualizations.

To generate R visuals, you need to write R codes on the editor window. It is possible when you have a basic knowledge of R packages. Microsoft makes this process easy and provided many R custom visuals which is like other visuals where you can drag and drop the fields on the respective axis.

R custom visuals doesn’t require R codes.

Another option that you can easily create R visuals using ggplot2 builder without writing much code.

Esquisse is a small add-in to R studio helps you to interactively explore your data by visualizing it with the ggplot2 package. It allows you to draw bar graphs, curves, scatter plots, histograms, then export the graph or retrieves the code generating the graph.

Refer the below URL,

https://github.com/dreamRs/esquisse

Follow the below steps to use this on your Power BI Desktop.

You need to have R studio installed on your machine

Install the devtools using below command.

install.packages(“devtools”)

Install the “dreamRs/esquisse” using below line of code

devtools::install_github(“dreamRs/esquisse”)

install.packages(“ggplot2”)

You need to perform the above steps in the R studio.

Once above steps are performed then you are good to go with Power BI Desktop.

You can take any dataset which you want to use it for R visuals. Try to have different columns like date, number string to experience all the visuals from ggplot2.

Add the R visual into the canvas area and it will open the editor below. To add a R script, you need to choose the fields from your dataset.

When you added the fields, you can see the R editor enabled to write codes.

Copy and paste the below line of code and click the run button.

esquisse:::esquisser()

It will open your browser and load the ggplot2 builder.

It will look like below.

First, you need to choose the dataset from the drop down of the data.frame list.

It will show all the columns as variables. You need to select all or whichever you want to use it for your visuals. Then finally choose the selected variables will be added.

On the Left top, you can see “auto”, you can click and see what are the visuals are supported as of now.

Next, you need to drag and drop the variables on respective sections. The sections are,

X Axis

Y Axis

Fill

Color

Size

Based on the data type you can choose different visuals. Sometimes few visual will not be enabled, if that is the case then your data is supported for those visuals.

To customize the visual, you can use the bottom bar options.

Label & Title

Plot Options

Data – Filter

Once you satisfied with the visual then you can copy the generated code and paste it on the R editor in Power Bi Desktop.

Before running the script, you need to comment on the previously added line of script and add the below line of code.

Library (ggplot2)

Then run the script.

It will generate the R visual on your report.

Thanks. Let me know if you have any doubts. Reach me on hari@yoursqlman.com.

About the Author

Hariharan Rajendran author

Hariharan Rajendran is a Microsoft Certified Trainer and Lead BI Solutions Consultant with 8+ years of experience in Database, BI and Azure platforms. Hariharan is also an active community leader, speaker & organizer and leads the Microsoft PUG (Power BI User Group – Chennai), SQLPASS Power BI Local Group – Chennai and an active speaker in SQL Server Chennai User Group and also a leader in Data Awareness Program worldwide events. Hariharan also frequently blogs (www.dataap.org/blog), provides virtual training (on ad-hoc basis) on Microsoft Azure, Database Administration, Power BI and database development to worldwide clients/audience.

Comments Are Closed!!!