Re: Correlation Plot

Moderator
12390 Views
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
Advisor
Posts: 50
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

Mike Carlo ( https://powerbi.tips )
mike@PowerBI.Tips
Moderator
Posts: 90
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

Highlighted
Moderator
Posts: 90
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?
Advisor
Posts: 50
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

Mike Carlo ( https://powerbi.tips )
mike@PowerBI.Tips
Regular Visitor
Posts: 19
Registered: ‎04-25-2018

Re: Correlation Plot

Hi,

 

After reading your nice posts, I need some help.

 

(Sorry, I m beginner on Power BI).

 

https://app.powerbi.com/view?r=eyJrIjoiNGNjYWEyMDItMmVhYS00OTVmLTgxM2ItYjFmMjYyODVmMDU5IiwidCI6IjBiO...

 

 

I would like to build graphs or indicators in order to see correlations between countries in import trade according 2 variables : weights in TON and volumes in USD.

 

 

I added this code but it doesn't work : 

 

require("corrplot")
library(corrplot)

M <- cor(dataset)

corrplot(M, method = "circle", tl.cex=0.6, tl.srt = 45, tl.col = "black", type= "upper", order="hclust")

 

 

 

If you have any suggestions, please advise.

 

Thank you in advance for your time and help,

 

Jaouad

Attachment
Regular Visitor
Posts: 17
Registered: ‎02-02-2017

Re: Correlation Plot

For a while now, I am experiencing a problem with Correlation plot.

 

As I am using the same file sample with the same data and the same fields, but now importing the Correlation Plot visual from the visual market, I tried to replicate the same analysis, however, I always have the same error:

 

"Some columns are not numeric, or constant. Not enough input dimensions"

 

I have all the packages installed, everything, but always the same error, even if I type the code at the R script.

 

Any help with this?

 

Thank you in advance

Attachment