Going crazy with forceNetwork in R: no edges displayed

后端 未结 4 967
后悔当初
后悔当初 2021-01-20 17:44

I\'ve been trying to plot a network using networkD3 package in R for a week now. The simpleNetwork function works normally, but it doesn\'t allow much

4条回答
  •  孤独总比滥情好
    2021-01-20 18:24

    I was having the same problem (simpleNetwork working normally, forceNetwork first displaying only nodes & no edges, then subsequently no display at all).

    The problem (which you presumably fixed when you "rebuilt dataframes starting numbering from 0") was your original Links data, edg, starting from 1 instead of 0?

    The networkD3 documentation, http://christophergandrud.github.io/networkD3/, has this note:

    Note: You are probably used to R’s 1-based numbering (i.e. counting in R starts from 1). However, networkD3 plots are created using JavaScript, which is 0-based. So, your data links will need to start from 0.

    Re. incorrect data types which I also originally thought might be the problem, I tested casting all the different columns (except the factor variable for the NodeID) as.numeric vs as.integer - however having now corrected my data to be 0-based instead of 1-based, my forceNetwork display works normally with either data type.

    Hope this helps!

提交回复
热议问题