Correlation Plot

Moderator
5999 Views
Highlighted
Moderator
Posts: 17
Registered: ‎09-29-2015

Correlation Plot

[ Edited ]

 

report_corrplot.JPGDescription

Correlation plots can be used to quickly find insights, showing what otherwise would require lots of iterative slicing and dicing of your data.

Download this sample to see how a correlation plot can inform marketing strategies in different market segments.

 

Prerequisites (The sample .pbix files will not work without these prerequites completed)

1. Install R Engine

Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately install R on your local computer. You can download and install R for free from many locations, including the Revolution Open download page, and the CRAN Repository.

 

2. Install the required R packages.

Download the R script attached to this message and run it to install all required packages on your local machine. 

 

Required R packages:

corrplot

 

Tested on:

CRAN 3.3.1, MRO 3.3.0, powerbi.com

 

Legal Disclaimers:

Terms of Service and Third Party Programs.

 

Attachment
Attachment
Attachment
Regular Visitor
Posts: 21
Registered: ‎12-17-2015

Re: Correlation Plot

This is a great R visual.  I have taken some time to build a complete tutorial on how to 1. Install R, 2. add R code to PowerBI, 3. Manipulate the code to change the visual.  You can follow along and learn how to build this here (www.PowerBI.Tips).

 

Enjoy,

Mike

Moderator
Posts: 52
Registered: ‎08-10-2016

Re: Correlation Plot

Member
Posts: 66
Registered: ‎10-05-2016

Re: Correlation Plot

I love what you did here with this visual and it works perfectly in my PowerBI Desktop.  However, when I try to view this from Power BI intranet, I get this error.  I have tried to correct this by modifying the function and corrplot lines of code, with no success:

#verify if the column is numeric and non-constant
correctColumn <- function(someColumn) { !is.null(someColumn) && is.numeric(someColumn) && length(unique(someColumn)) > 1 }
corrplot(M, method=method, order=order, type=type, addrect=addrect, #na.label = "?",
na.rm=TRUE, 
          mar = defMar, tl.col = tl.col, tl.cex=tl.cex,  tl.srt=60, cl.ratio=0.2, cl.align="r",  
       number.digits=number.digits, number.cex=number.cex, addCoef.col=addCoef.col)

How can I fix this?

 

correlation script runtime error.jpg

Moderator
Posts: 52
Registered: ‎08-10-2016

Re: Correlation Plot

Hi  ironryan77

Can you please share with me the PBIX, so I'd be able to reproduce this error?  

Member
Posts: 66
Registered: ‎10-05-2016

Re: Correlation Plot

Thanks, but I think I got this working now!

Member
Posts: 66
Registered: ‎10-05-2016

Re: Correlation Plot

  1. How does corrplot calculate correlation matrices?
  2. Is this based on Pearson’s correlation coefficient formula? When I try plugging in my values to this formula, they do not match.
  3. Does corrplot remove duplicate rows?
  4. Does it handle aggregated columns?
Regular Visitor
Posts: 21
Registered: ‎12-17-2015

Re: Correlation Plot

Here is the documentation on the corrplot function that was used. 

 

https://cran.r-project.org/web/packages/corrplot/corrplot.pdf