Sharon's avatar
Sharon
Microsoft Employee
10 years ago

Correlation Plot

 

Description

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.

 

16 Replies

  • Mike_Carlo's avatar
    Mike_Carlo
    Most Valuable Professional

    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

  • ironryan77's avatar
    ironryan77
    Kudo Commander

    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?

     

    • boefraty's avatar
      boefraty
      Microsoft Employee

      Hi  ironryan77

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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

    • boefraty's avatar
      boefraty
      Microsoft Employee

      Hi Anonymous, 

      Make sure the columns are not aggregated. 

  • Katalo's avatar
    Katalo
    Frequent Visitor

    Hello!

    I'm new to R visuals in Power BI. But I've installed Microsoft R Open 3.5.1 and the visual in the example. But when I insert values the visual gives ni this error:

     

    Error Message:
    R script error.
    Loading required package: corrplot
    Warning messages:
    1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called 'corrplot'
    2: In libraryRequireInstall("corrplot") :
    *** The package: 'corrplot' was not installed ***
    Error in corrplot(M, method = method, order = order, type = type, addrect = addrect, :
    could not find function "corrplot"
    Execution halted

     

    What am I missing here?

    • JaouadZrhibi's avatar
      JaouadZrhibi
      Helper I

      Hi Katalo,

       

      I m really sorry, I am also a beginner in Power BI.

       

      Hope you will find the solution.

       

      Regards,

       

      Jaouad

    • smpa01's avatar
      smpa01
      Community Champion

      Kataloprobably you figured it out by now. If not, I am not sure if the following steps solve your problem but this is my two cents. Initially, I faced a lot of trouble with R (got the similar message as you did). After a long trial and error and knocking on many doors I solved it by using the following

       

      When I run R in PBI, the packages are accessed by PBI from C:\Users\xxxx\Library.

       

      However, when I install the packages from R studio, the installed packages get saved in C:\Users\xxxx\Documents\R\win-library\3.5.

       

      After installing a package, I copy that package

      from

      C:\Users\xxxx\Documents\R\win-library\3.5

      to

      C:\Users\xxxx\Library

       

      Everything seems to work fine after that.