<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [need help] Error occurs when creating Sankey diagram by R script in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/need-help-Error-occurs-when-creating-Sankey-diagram-by-R-script/m-p/703199#M2213</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I did data transform by creating a new table with DAX, and the format of new table is sankey format: Source, Target, Occurs(Please refer to below table1)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sankeytable.jpg" style="width: 932px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/167590i7B5F5F9BCB5860AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="sankeytable.jpg" alt="sankeytable.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I trying to create sankey diagram with R visulization, here is the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;dataset &amp;lt;- data.frame(Source, Target, Occurs)
dataset &amp;lt;- unique(dataset)
library(networkD3)
dataset$Source = as.character(dataset$Source)
dataset$Target = as.character(dataset$Target)
Sankeylinks&amp;lt;-dataset
Sankeynodes&amp;lt;-data.frame(name=unique(c(Sankeylinks$Source,Sankeylinks$Target)))
Sankeynodes$index&amp;lt;-0: (nrow(Sankeynodes) - 1)
Sankeylinks&amp;lt;-merge(Sankeylinks,Sankeynodes,by.x="Source",by.y="name")
Sankeylinks&amp;lt;-merge(Sankeylinks,Sankeynodes,by.x="Target",by.y="name")
Sankeydata&amp;lt;-Sankeylinks[,c(4,5,3)];
names(Sankeydata)&amp;lt;-c("Source","Target","Occurs")
Sankeyname&amp;lt;-Sankeynodes[,1,drop=FALSE]
# draw sankey network
sankeyNetwork(Links=Sankeydata,Nodes=Sankeyname,Source="Source",Target="Target",Value="Occurs",NodeId="name",fontsize=8,nodeWidth=20)&lt;/PRE&gt;But there is error occured.&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="error.jpg" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/167594iD995045A4B8F91BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="error.jpg" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;what is the issue with my script?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 30 May 2019 09:11:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-30T09:11:51Z</dc:date>
    <item>
      <title>[need help] Error occurs when creating Sankey diagram by R script</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/need-help-Error-occurs-when-creating-Sankey-diagram-by-R-script/m-p/703199#M2213</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I did data transform by creating a new table with DAX, and the format of new table is sankey format: Source, Target, Occurs(Please refer to below table1)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sankeytable.jpg" style="width: 932px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/167590i7B5F5F9BCB5860AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="sankeytable.jpg" alt="sankeytable.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I trying to create sankey diagram with R visulization, here is the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;dataset &amp;lt;- data.frame(Source, Target, Occurs)
dataset &amp;lt;- unique(dataset)
library(networkD3)
dataset$Source = as.character(dataset$Source)
dataset$Target = as.character(dataset$Target)
Sankeylinks&amp;lt;-dataset
Sankeynodes&amp;lt;-data.frame(name=unique(c(Sankeylinks$Source,Sankeylinks$Target)))
Sankeynodes$index&amp;lt;-0: (nrow(Sankeynodes) - 1)
Sankeylinks&amp;lt;-merge(Sankeylinks,Sankeynodes,by.x="Source",by.y="name")
Sankeylinks&amp;lt;-merge(Sankeylinks,Sankeynodes,by.x="Target",by.y="name")
Sankeydata&amp;lt;-Sankeylinks[,c(4,5,3)];
names(Sankeydata)&amp;lt;-c("Source","Target","Occurs")
Sankeyname&amp;lt;-Sankeynodes[,1,drop=FALSE]
# draw sankey network
sankeyNetwork(Links=Sankeydata,Nodes=Sankeyname,Source="Source",Target="Target",Value="Occurs",NodeId="name",fontsize=8,nodeWidth=20)&lt;/PRE&gt;But there is error occured.&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="error.jpg" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/167594iD995045A4B8F91BB/image-size/large?v=v2&amp;amp;px=999" role="button" title="error.jpg" alt="error.jpg" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;what is the issue with my script?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 May 2019 09:11:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/need-help-Error-occurs-when-creating-Sankey-diagram-by-R-script/m-p/703199#M2213</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-30T09:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: [need help] Error occurs when creating Sankey diagram by R script</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/need-help-Error-occurs-when-creating-Sankey-diagram-by-R-script/m-p/704557#M2221</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error on your picture says that field name is unavailable.&lt;/P&gt;&lt;P&gt;Please check that you correctly typed all your fileds names.&lt;/P&gt;&lt;P&gt;Also, pay attention please that using fileds must be added to "Values" bucket to be available in a script regarding &lt;A href="https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals" target="_self"&gt;this article&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Evgenii Elkin,&lt;BR /&gt;Software Engineer&lt;BR /&gt;Microsoft Power BI Custom Visuals&lt;BR /&gt;pbicvsupport@microsoft.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 14:53:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/need-help-Error-occurs-when-creating-Sankey-diagram-by-R-script/m-p/704557#M2221</guid>
      <dc:creator>v-evelk</dc:creator>
      <dc:date>2019-05-31T14:53:26Z</dc:date>
    </item>
  </channel>
</rss>

