首页 文章

PowerBi中的RScript网络 Map

提问于
浏览
0

我是PowerBI的新手,我正试图让我的R网络图显示在PowerBI中 .

我的脚本使用以下代码在R中按预期工作:

install.packages("maps", repos='http://cran.us.r-project.org')
install.packages("geosphere", repos='http://cran.us.r-project.org')
install.packages("readxl", repos='http://cran.us.r-project.org')

library("maps")
library("geosphere")
library("readxl")


airports <- read_excel("C:/Users/jeffrey.tackes/Desktop/BASEMAPPING.xlsx", 
sheet="ASI Solo")
flights <- read_excel("C:/Users/jeffrey.tackes/Desktop/BASEMAPPING.xlsx", 
sheet="edges")

map("world", col="skyblue",  border="gray10", fill=TRUE, bg="black")
points(x=airports$long, y=airports$lat, pch=19, 
   cex=1, col="orange")

# Generate edge colors
col.1 <- adjustcolor("orange red", alpha=0.4)
col.2 <- adjustcolor("orange", alpha=0.4)
edge.pal <- colorRampPalette(c(col.1, col.2), alpha = TRUE)
edge.col <- edge.pal(100)

# For each path, we will generate the coordinates of an arc that connects
# its star and end point, using gcIntermediate() from package 'geosphere'.
# Then we will plot that arc over the map using lines().

for(i in 1:nrow(flights))  {
  node1 <- airports[airports$ID == flights[i,]$from,]
  node2 <- airports[airports$ID == flights[i,]$to,]

  arc <- gcIntermediate( c(node1[1,]$long, node1[1,]$lat), 
                     c(node2[1,]$long, node2[1,]$lat), 
                     n=1000, addStartEnd=TRUE )
  edge.ind <- round(100)

  lines(arc, col=edge.col[edge.ind], lwd=edge.ind/30)
}

我的问题是如何在PowerBI中显示它?当我导入RScript时,它显示我的4个表,2个包含原始数据源,以及在脚本中创建的2个数据帧(Node1和Node2)

如果我去PowerBI里面的R Visuals,这就是我迷路的地方 .
我尝试从我的R代码添加我的2个原始表,添加所有字段,然后将我的R代码复制到PowerBI中的R编辑器,但这不起作用 .

有帮助吗?

1 回答

相关问题