Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
fverhagen
New Member

R print or summary visualization

Does anyone know how you can show the result of an R script in a dashboard? 

And I don't mean the charts, but for example the result of the r script :

 

input <- warpbreaksprint(head(input))

output <-glm(formula = breaks ~ wool+tension, data = warpbreaks, family = poisson) print(summary(output))

 

Thank You!

5 REPLIES 5
bice_cold
Frequent Visitor

I haven't tested the solution on summary() outputs, but I have done this with a numeric output value. A way around this is to utilize ggplot() + geom_text() in order to output a text value. I used this in a predict function where:

 

p <- predict(fit, test.data)

 

ggplot() + geom_text(aes(0, 0, label = p))

 

That got me a plot that has my numeric value in the center. If you mess around with the arguments available for the function you can make it look a lot nicer than that. It's not great, but it works until Power BI starts allowing us to output printed values to a report.

 

If that works, please mark it as a solution. Thanks!

BeardyGeorge
Advocate I
Advocate I

it's a bit of a workaround, but the gridExtra package should be able to do what you're after - grid.table()  instead of print can be used to display the result of the summary function (see here for more detail on what it can do).

Note that this might not be completely what you're after, as it produces an image and displays that, rather than an actual table you can copy data out of.

Another way would be to save the output in a text file and then create a table visual in PowerBi and pull the data with 0 width. The issue here is one would need to refresh the table visual.

 

require(gridExtra)
pathToProject <- "F:\\PowerBIDocuments\\"
t <- summary(dataset$hwy)
grid.table(t)
out <- capture.output(t)
cat(out, file=paste0(pathToProject,"results.txt"), sep="\n", append=FALSE)
ankitpatira
Community Champion
Community Champion

@fverhagen In power bi desktop you can use R script visual to visualise output of R scripts. However it is currently not supported in power bi service and you will only find it working in power bi desktop. Please vote for my idea here to have R visual support in power bi service. Check this blog post on using R visuals in power bi desktop.

 

Capture.PNG

Unrelated and doesn't answer the question (explicitly about outputting the data from an R script, not a visualisation).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.