Using R in Power BI

 Already offering a number of great visualizations, Power BI has truly done it—the use of R script has been incorporated. This allows the user to have more options when it comes to data visualizations. In order to utilize R visualizations in Power BI, one must first download the R software (if one hasn’t already). R is a free software that can be downloaded by clicking here.

Once Power BI and R has been downloaded, you can now use the R visualizations in Power BI. If this is your first time using the R visualizations option in Power BI, I recommend that you become familiar with it by clicking here.

Example:

Before running my script in Power BI, I created a script in R and ran it first to make sure it worked as expected. To test the R visualizations in Power BI, I decided to use something simple, but also something that is not available as a standard Power BI visualization—side-by-side boxplots!

rboxplotsAfter making sure my code worked in R, it was time to replicate my side-by-side boxplots in Power BI. First, I had to load the data. Seeing that I used a csv file, I had two options: I could either load the file by clicking get data, then clicking csv, then looking for the file I used, or I could simply just click get data, hit more, scroll down to R Script (beta) and then enter in my R script. Since I already had my R script written, I decided to go with the second option.

rpostIn order to replicate my side-by-side boxplots, I had to actually create two separate visualizations using the field “Sales” as the value, and the field “Year” for the visual level filters for each visualization. In other words, I was not able to create one visualization that included two boxplots, but rather, I created two visualizations that each contained one boxplot and was filtered by different years. I did, however, have to tweak my R script just a little bit in order to produce my boxplots.

rpost2rpost2.5Overall, I would say this new feature is user friendly and easy to use, especially if you are familiar with R programming. While the kinks are still being worked out, it can only get better. With so many packages available in R, the sky is truly the limit. Seriously! Currently there are over 7,700 packages available in the CRAN package repository. Many of the packages come standard with R, while others have to be downloaded and loaded in each session the user wishes to use it. These packages range from a series of statistical tools, including packages that can help with forecasting and predictive analysis, and even twitter scraping. Click here for list of packages or use this URL: https://cran.r-project.org/web/packages/.