Using R functions and scripts to create visuals within Power BI
The R programming language, including its powerful and extensible features in data processing, advanced analytics, and visualization, is integrated with Power BI. An R script can be used as a data source for a Power BI dataset, as a data transformation and shaping process within an M query, and as its own visualization type within Power BI reports and dashboards. Like standard Power BI visuals, R script visuals directly leverage the relationships defined in the data model and can be dynamically filtered via other visuals, such as slicers.
In this recipe, two histogram visualizations are created in Power BI Desktop with R scripts, one with R's standard distribution base graphics and another with the popular ggplot2 visualization package. The R Script Showcase, referenced in the See also section, contains many additional examples of R script visuals for Power BI, such as Correlation Plots, Clustering, and Forecasting.