简体   繁体   English

如何在 Power BI 中使用 R 包?

[英]How to use R packages in Power BI?

I have plotted the graph using a code in R using library function which is part of certain package.我已经使用 R 中的代码使用库函数绘制了图形,该函数是某个包的一部分。

I want to use this code in powerbi to plot the graph.我想在 powerbi 中使用此代码来绘制图形。 But I am not able to add the package (library function) in power bi?但是我无法在power bi中添加包(库函数)?

For a Power BI Desktop scenario, it calls the R Installation specified in the Power BI Options.对于 Power BI Desktop 方案,它调用 Power BI 选项中指定的 R 安装。 So you need to add the packages you want via that R Installation.所以你需要通过 R 安装添加你想要的包。

For an app.powerbi.com scenario, you are limited to the list of packages they support, ref:对于 app.powerbi.com 方案,您仅限于它们支持的软件包列表,参考:

https://powerbi.microsoft.com/en-us/documentation/powerbi-service-r-visuals/ https://powerbi.microsoft.com/en-us/documentation/powerbi-service-r-visuals/

Just to clarify, are you trying to install packages or add packages that you already have into R?只是澄清一下,您是在尝试安装软件包还是将已有的软件包添加到 R 中?

Unfortunately Power BI isn't an IDE for the R language, so you will need to install the packages that you want via your R IDE or command prompt.不幸的是,Power BI 不是 R 语言的 IDE,因此您需要通过 R IDE 或命令提示符安装所需的包。

If you are trying to use packages that are already installed on your machine, for example, the package plotrix , then you can use the R script editor in the Visualisations tab like this:如果您尝试使用机器上已安装的包,例如包plotrix ,那么您可以在 Visualisations 选项卡中使用 R 脚本编辑器,如下所示:

require(plotrix)

or

library(plotrix)

Please post an update to show if this has helped you.请发布更新以显示这是否对您有所帮助。 :) :)

Was just now gone through the same problem: everything was loading fine except the visual created with R which required me to use ggplot2 and it was giving an error saying刚刚遇到了同样的问题:除了用 R 创建的视觉效果需要我使用ggplot2并且它给出了一个错误说

there is no package called ggplot2没有名为 ggplot2 的包

In order to solve it, opened RStudio and in the console ran为了解决它,打开RStudio并在控制台中运行

install.packages("ggplot2")

安装 ggplot2

Then, went back to PowerBI and clicked "Atualizar" (which means "Update" in portuguese)然后,返回 PowerBI 并单击“Atualizar”(这意味着葡萄牙语中的“更新”)

PowerBI 葡萄牙语更新

and the visual showed up without any errors.并且视觉显示没有任何错误。

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

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