Kat*_*ne 2 r linear-regression powerbi
我在R中进行了线性回归,并提取了重要变量及其p值。我需要导入那些要在Power BI中导入的变量。但是,Power BI仅支持R的视觉效果,回归结果以文本形式显示。有什么方法可以将其转换为图像,例如在R中通常会弹出图吗?谢谢。
编辑:Power BI不支持gplots包。可以在这里找到受支持的软件包https://powerbi.microsoft.com/zh-cn/documentation/powerbi-service-r-visuals/#supported-packages
这是您问题的答案以及可复制的示例。您可以使用软件包的textplot功能gplots。
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)
Run Code Online (Sandbox Code Playgroud)
如果您想让R与PowerBI交流,则有更好的选择。微软一直在为其越来越多的产品提供对R的支持,而PowerBI现在具有强大的R集成。签出:https : //powerbi.microsoft.com/en-us/documentation/powerbi-desktop-r-scripts/