How To Install R Packages In Power BI

by | Power BI

Power BI has always proven to be such a dynamic tool for data professionals, not only because of its ease of use and wide range of capabilities, but also because of its easy integration with other tools, platforms, and programming languages. This is evident when you learn how to install R packages in Power BI.

R is a programming language that proves most useful in data visualization and predictive analytics.

When used in Power BI, it allows users to transform data without the need to change the data model it is sourced from.

To use R in Power BI, you’ll need R packages.

An R package is a collection of codes, data and formats stored within a library.

R packages allow your R scripts and visuals to run.

What You Need To Install R Packages

If you’re using custom visualizations using R, there are a few packages that need to be installed before you can connect and run R scripting in Power BI. There is a long list of R packages that are supported in Power BI that can be found in Microsoft documentation.

R packages are normally downloaded through code repositories like CRAN and github.

To install R packages, just follow these steps:

  1. Open the R script Editor.
  2. Use the command install.packages, then name the package you want to install.
  3. Specify a library.

Here’s an example of how the command will look like:

Without the right package, you’ll end up with an error message when you try to run your script. So make sure the right packages are installed and that the package is supported.

Requirements and Limitations

There are a few requirements and limitations to take note of when you start installing R packages into your Power BI desktop.

  • The current R runtime for Microsoft R is 3.4.4
  • Power BI usually supports R packages that use open-source licenses, with a few limitations.
  • Power BI does not support custom or private R packages IF you’re working with custom R visuals, so it’s recommended that private packages are uploaded to CRAN first before using them on Power BI.
  • For regular R visuals, custom R packages are supported.
  • Power BI does not support R packages that run client-server queries online (like RgoogleMaps) for security reasons.
  • Some R packages depend on other platforms or systems to run, so make sure these dependencies are also supported by Power BI.

To be on the safe side, always consult the supported list of R packages.

How To Connect Power BI To R

Integrating R into Power BI is simple. In the Power BI desktop, go to File, then go to Options and settings. Then, click on Options.

How To Install R Packages In Power BI

This opens up a new window where you can choose to connect Power BI to R. This is the same window where we connected Python to the Power BI desktop in a previous tutorial.

Compared to Python, however, the R language is much easier to connect and leaves us with only a few options to tweak. The most important part here is making sure that the home directory is set right.

How To Install R Packages In Power BI

The great thing about Power BI is that it also guides you through the process of installing R. Just click on the link that says “How to install R” and you’ll be led to the Microsoft document that gives you the details.

Once you click on OK, you are good to go and should be able to run R scripts in your Power BI desktop.

***** Related Links *****
Three Ways To Use R Script In Power BI
Power BI With R And RStudio: How To Get Started
R In Power BI: Downloading R And RStudio

Conclusion

Again, the R language is most useful when it comes to predictive analytics and visualization. These two are critical to any organization, making it even more important to understand how to install R packages in Power BI.

Using R packages within Power BI may have its own set of limitations, but in this case, the benefits far outweigh the disadvantages. Having the chance to access thousands of custom analysis and visuals is just one of these benefits.

All the best,

Sam

Related Posts

Comprehensive Data Analysis using Power BI and DAX

Data Model Discovery Library

An interactive web-based application to explore and understand various data model examples across multiple industries and business functions.