3

I use R notebook for data analysis report.
I want to render Sankey and d3tree htmlwidgets on R notebook simultaneously.

I put snakey and then d3tree example code in r chunk, output is well printed on rstudio.
When I entered preview button, sankey output well appeared on html.
But, d3tree output doesn't render on html.

I tryed that put d3tree and then sankey. the result is that two of d3tree and sankey dosen't render on html.

what is the problem?? Can i solve these?

the example code like below

---
title: "test"
output: html_notebook
---
```{r, echo=FALSE}
library(networkD3)
library(treemap)
library(d3treeR)
```

```{r, echo=FALSE}
net_cycles <- list(
  links = data.frame(
    source = c(0,0,0,1,1,5),
    target = c(1,2,3,4,5,0),
    value = 10
  ),
  nodes = data.frame(
    name = letters[1:6]
  )
)
```

```{r, echo=FALSE}
data(business)
business$employees.growth <- business$employees - business$employees.prev
tree <- treemap(business,
          index=c("NACE1", "NACE2"),
          vSize="employees",
          vColor="employees.growth",
          type="value",
          palette="-RdGy",
          range=c(-30000,30000))
```


```{r}
sankeyNetwork(
  net_cycles$links,
  net_cycles$nodes,
  Value = "value"
)

d3tree2(
  # Brewer's Red-White-Grey palette reversed with predefined range
  tree
  ,rootname = "World"
)
```
Rokmc1050
  • 463
  • 1
  • 6
  • 16
  • 3
    Besides that your `eval=FALSE` statements will need to be changed to `eval=TRUE`, I'm fairly certain that the problem is that networkD3 has recently been updated to D3v4 while d3treeR still uses D3v3. This is a known problem with shiny/htmlwidgets/flexdashboards etc... when mixing two widgets that use different versions of the same JavaScript framework, htmlwidgets chooses the most recent version of the framework and only loads that one. In most cases this is ok, but in the case of D3v3 to D3v4, many breaking changes were made, so it causes problems. – CJ Yetman Mar 23 '17 at 09:31
  • 1
    Thanks CJ. For more reference, see https://github.com/christophergandrud/networkD3/issues/162. – timelyportfolio Mar 23 '17 at 12:30
  • Hello, Is there a timeframe for when d3treeR will be updated to d3v4? Or, is there a way to install the old version of networkd3 that uses d3v3? I see the [networkd3 archive](https://cran.r-project.org/src/contrib/Archive/networkD3/) on CRAN, but I don't know which version to install for d3v3. – Adrian Martin Aug 30 '17 at 20:42

0 Answers0