R networkD3 更改节点 IMG

R networkD3 change node IMG

我想将基本节点图像替换为 R 中 networkD3 包中的自定义 jpg。

这是一个例子:

library(networkD3)

# Load data
data(MisLinks)
data(MisNodes)

# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes,
            Source = "source", Target = "target",
            Value = "value", NodeID = "name",
            Group = "group", opacity = 0.8)

所以我想创建一个这样的节点:

而不是这个:

可能吗?

I would like to replace the basic node image to a custom jpg in networkD3 package in R. [...] For me it is also good with any other interacive R network package

例如,您可以这样做

library(networkD3)
library(visNetwork)
library(dplyr)
data(MisLinks)
data(MisNodes)
visNetwork(
  MisNodes %>% 
    rename("label"=name) %>% 
    mutate(id = seq_len(nrow(MisNodes))-1),
  MisLinks %>% 
    rename("from"=source, "to"=target)
) %>%
  visNodes(
    shape = "image", 
    image = "http://cdn0.iconfinder.com/data/icons/octicons/1024/mark-github-128.png"
  )

给你