2

I did linear regression in R and extracted the significant variables together with their p-values. I need to import those variables to be imported in Power BI. However, Power BI only supports visuals from R and the regression result is in text. Is there any way that I can convert it into an image like how plots would usually pop-up in R? Thanks.

Edit: Power BI does not support gplots package. Supported packages can be found here https://powerbi.microsoft.com/en-us/documentation/powerbi-service-r-visuals/#supported-packages

Katherine
  • 33
  • 1
  • 1
  • 7

1 Answers1

6

Here's an answer to your question along with a reproducible example. You can use the textplot function of the gplots package.

library(gplots) # For the textplot function
library(tidyverse) # Should be a part of all data science workflows
library(broom) # Gives us the tidy function

# Generate some dummy data for the regression
dummy_data <- data.frame(x = rnorm(327), y = rnorm(327))

# Run the regression and extract significant variables
reg <- lm(y ~ x, data = dummy_data) %>%
  tidy() %>%
  filter(term != "(Intercept)") %>%
  filter(p.value < 1.01) %>% # Change this to your desired p value cutoff
  select(term)

# Plot the significant variables as an image
textplot(reg$term)

If you want to make R talk to PowerBI there's a better option. Microsoft has been building support for R into more and more of its products and PowerBI now has a powerful R integration. Check it out: https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-r-scripts/

Andrew Brēza
  • 7,705
  • 3
  • 34
  • 40
  • 1
    Thanks this one works with R but I just found out that gplots is not supported by Power BI. Can you please give me alternatives? – Katherine Jan 07 '17 at 03:07