简体   繁体   English

如何在Power BI仪表板中显示交互式R数据框

[英]How to display an interactive R data frame in a Power BI dashboard

I would like to display an R dataframe as a table in Power BI. 我想在Power BI中将R数据帧显示为表格。 Using the "R script visual" widget, here is one possible solution: 使用“ R script visual”窗口小部件,这是一种可能的解决方案:

library(gridExtra)
library(grid)
d<-head(df[,1:3])
grid.table(d)

reference: [ https://cran.r-project.org/web/packages/gridExtra/vignettes/tableGrob.html][1] 参考:[ https://cran.r-project.org/web/packages/gridExtra/vignettes/tableGrob.html] [1 ]

As stated in the reference - this approach only works for small tables. 如参考中所述-这种方法仅适用于小型表。

Is there an alternative approach that will allow an R data frame to be displayed as a table in Power BI - specifically for larger tables that can be 'scrolled'? 是否有其他方法可以将R数据框显示为Power BI中的表-专门针对可以“滚动”的较大表?

Don't use an R Visualization . 不要使用R Visualization Use the Run R Script functionality in the Power Query Editor instead ( Home > Edit Queries ). 而是使用Power Query EditorRun R Script功能(“ Home > Edit Queries )。

If you follow the steps in posts post1 and/or post2 you'll see how you can import and transform any data into any table you want using R. 如果按照帖子post1和/或post2中的步骤进行操作 ,您将看到如何使用R将数据导入并将其转换为任何表。

So with a simple dataset such as: 因此,使用简单的数据集,例如:

A,B
1,11
2,19
3,18
4,19
5,18
6,12
7,12
8,19
9,13
10,19

... you can produce a scrollable table of any format in Power BI: ...您可以在Power BI中生成任何格式的可滚动表:

R script: R脚本:

# 'dataset' holds the input data for this script
dataset$C <- dataset$B*2
dataset2 <- dataset

Power Query Editor: 电源查询编辑器: 在此处输入图片说明

Power BI Desktop table: Power BI Desktop表:

在此处输入图片说明

Power BI Desktop interactive table: Power BI Desktop交互式表:

And you can easily make the table interactive by introducing a slicer : 您可以通过引入slicer轻松地使表具有交互性:

在此处输入图片说明

It appears that you now also have the possibility of importing an R DataTable visualization from the Power BI Marketplace: 看来您现在也可以从Power BI Marketplace导入R DataTable可视化文件:

在此处输入图片说明

With the same dataset, you'll end up with this: 使用相同的数据集,您将得到以下结果:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM