Power BI has an extensive capability to integrate with other tools and languages. In this blog, I am going to explore one of the important feature of Power BI. How to integrate Power BI with R and do some data analysis with this feature.
We need to install Microsoft Open R (microsoft-r-open-3.5.3.exe) and R studio.
Install required R packages: I had installed ggplot2, datasets for this assignment.
I am using iris dataset for this experiment.
If Power BI is already installed then go to File – > Options and Settings – > Options -> R Scripting. Now change in two places, one for R installation directories and another for R IDE. Save the settings and now ready for integration.
Click on Get Data -> Other – > R Script, paste R script for data import.
Tables are available for report creation
Click on R script visual and display dialog box with “Enable script visuals” message. Click on enable and get ready for report creation.
After clicking on any field from the table, R script editor will be enabled.
I had created 4 reports for visualization.
#Report1: library(ggplot2) ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) + geom_point() #Report2 library(ggplot2) ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species, size=Petal.Width)) + geom_point(alpha=0.7) + ggtitle("Plot of sepal length vs. petal length") #Report3 library(ggplot2) ggplot(iris, aes(x = Sepal.Length, fill=Species)) + geom_histogram(binwidth = .2) #Report4 library(ggplot2) ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species)) + geom_point() + facet_wrap(~Species) + ggtitle("Plot of sepal length vs. petal length")
Here is the final page visualization.
I had faced some challenges during this project.
Power BI Desktop: Initially I had installed normal open source R. But during configuration and integration I had faced some package version mismatch issues. Then I installed Microsoft Open R and solved all the issues.
Power BI Service: To see these R reports in Power BI Service, we need licensed id.