'Can anyone tell me what I am doing wrong when transferring my R code to powerbi?

I created a Sankey in R, but when I try to replicate the same code into a Power BI R visual script, I get no errors but no visuals appear. This is the code I entered into PowerBI

library(networkD3) # sankey plots
library(dplyr)    # data manipulation

# put your df in two columns, and preserve the ordering in many levels (columns) with paste0
links <- data.frame(source = c('Base level component','Level 6','Level 5','Level 4','Level 
3','Level 2','Level 1'),
                target   = c('Level 6','Level 5','Level 4','Level 3','Level 2','Level 
                           1','Level 0'))

# now convert as character
links$source <- as.character(links$source)
links$target<- as.character(links$target)

nodes <- data.frame(name = unique(c(links$source, links$target)))

links$source <- match(links$source, nodes$name) - 1
links$target <- match(links$target, nodes$name) - 1
links$value <- 1 # add also a value
sankeyNetwork(Links = links, Nodes = nodes, Source = 'source',
             Target = 'target', Value = 'value', NodeID = 'name',
             height = NULL, width = NULL, nodeWidth = 20, nodePadding = -20)

Anyone know what I am doing wrong here? I have a feeling it has something to do with how I am calling my Values possibly.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source