Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I was trying to draw a correlation plot in powerBI using R scripts. But it is showing different results.
Here is my R scripts code-
library(corrplot)
A = cor(na.omit(dataset))
corrplot(A, method = "number", col="black")
output from R is like the below picture-
And the output from PBI is like the below picture-
Same dataset, but the values are not equal. Is there anything I missed?
Not necessarily. Note this comment in the Power BI code window:
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset <- data.frame(A, B, C, D, E, F, G, H, I)
# dataset <- unique(dataset)
Unless you also drop the index column and remove duplicates in your standard R script you are likely to get different results.
took me a couple tries but here you can see it gets the same result.
I know. But it still does not give me the same result.
Have you tried my version of the R code?
would you mind providing the sample data?
Your implementation of na.omit may lead to unintended side effects. As you specify it this will remove all rows where any of the columns is "NA"
Here is my result based on the data you provided. It has 3285939 rows but only 3117 rows will be left after the na.omit().
Yeah. It removes maximum rows, but my question is if I run the script in R and PBI separately, it gives me a different result. Shouldn't it be same?