[英]How to define dataset coming from Power BI in Custom R Visual
I am trying to create a custom visual in Power BI based on an R script much like in the example found at ( http://radacad.com/interactive-map-using-r-and-power-bi-create-custom-visual-part-1 ), Installed node.js, pbiviz successfully. 我正在尝试基于R脚本在Power BI中创建自定义视觉,就像在( http://radacad.com/interactive-map-using-r-and-power-bi-create-custom- visual-part-1 ),成功安装了node.js,pbiviz。 Once I get this custom visual in Power BI Desktop, I see all static data coming from sample iris dataset, But I want this to use my dataset coming from Power BI. 在Power BI Desktop中获得自定义视觉效果后,我将看到来自示例虹膜数据集的所有静态数据,但是我希望它使用来自Power BI的数据集。 how can I edit the script (shown below) to allow Power BI to use my own data rather than the data in the library? 如何编辑脚本(如下所示)以允许Power BI使用我自己的数据而不是库中的数据?
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly")
####################################################
################### Actual code ####################
g = qplot(`Petal.Length`, data = iris, fill = `Species`, main = Sys.time());
####################################################
############# Create and save widget ###############
p = ggplotly(g);
internalSaveWidget(p, 'out.html');
####################################################
When I attempt to change "iris" to a dataset, it can't find dataset. 当我尝试将“ iris”更改为数据集时,找不到数据集。 I've also tried adding dataset <- data.frame(MyColumns) but that did not help. 我也尝试添加数据集<-data.frame(MyColumns),但这没有帮助。
If I have table name as Dim - Product, Fact - Sales and Columns as Product Name and Total Sales. 如果我的表名称为Dim-Product,则为事实-Sales,列为Product Name和Total Sales。 How do I define this? 我该如何定义?
Any tutorial/video which has the example would really help. 任何带有示例的教程/视频都将真正有帮助。
Use cbind to create a dataframe with the objects you are sending from PBI. 使用cbind创建一个数据框,其中包含您要从PBI发送的对象。 Assuming all the objects you are sending are mandatory: 假设您要发送的所有对象都是必需的:
dataset <- as.data.frame(cbind(var1,var2,...)) 数据集<-as.data.frame(cbind(var1,var2,...))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.