0

I am trying to make Sankey graphs, however, the networkd3 package doesn't seem to work right. When I try to install it in R, the following error comes up:

Error: package or namespace load failed for ‘networkD3’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘igraph’

I am just starting out with R and can use your help to rectify this.

I am trying to make Sankey graphs using this package.

Tammy
  • 3
  • 2
  • Please remember that Stack Overflow is not your favourite R forum, but rather a question and answer site for all programming related questions. Thus, always include the tag of the language you are programming in, that way other users familiar with that language can more easily find your question. Take the [tour] and read up on [ask] to get more information on how this site works, then [edit] the question with the relevant tags. – Adriaan Aug 15 '23 at 12:30
  • What happens if you run `install.packages("igraph")` first? – MrFlick Aug 15 '23 at 13:51
  • I tried this too. where I installed I graph first, loaded it, and then tried loading networkd3, and still get the same error. – Tammy Aug 15 '23 at 13:58
  • It would be helpful to see the code you used to get this error, because only a few functions from {networkd3} require {igraph} – CJ Yetman Aug 18 '23 at 10:46

2 Answers2

0

Try uninstalling {networkD3} and {igraph}, and then re-installing {networkD3}...

remove.packages("networkD3")
remove.packages("igraph")
install.packages("networkD3")
CJ Yetman
  • 8,373
  • 2
  • 24
  • 56
-1

I see two solutions.

If you wish to continue using NetworkD3, you will need to install iGraph. This is what the error states. Please have a look at the documentation here: igraph-Installation.

Installing iGraph can be a little tricky depending on your machine you are working with. Another solution would be to use ggalluvial, a R library that works with ggplot to build sankey diagrams i.e. alluvial plots. You may find a nefty tutorial here: ggalluvial-tutorial

DoRemy95
  • 614
  • 3
  • 19