Data Analysis on IRIS data using Power BI and R

Image from Unsplash

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.

Prerequisites

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.

Configuration

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.

Get Data

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.

Troubleshooting

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: