I'm currently trying to plot images on my network graph in R. I'm relatively new to R, and am completely stuck trying to figure this out. Here's my syntax:
# First, getting the appropriate libraries
library(igraph)
library(png)
library(raster)
library(rasterImage)
test.edges <- read.csv("TestEdges.csv", header = TRUE, stringsAsFactors = FALSE)
test.nodes <- read.csv("TestNodes.csv", header = TRUE, stringsAsFactors = FALSE)
img.D <- readPNG("./images/doctor.png")
img.L <- readPNG("./images/lab.png")
img.D <- as.raster(img.D)
img.L <- as.raster(img.L)
# Attempting to graph with images
graph.7 <- graph_from_data_frame(d = test.edges,directed = TRUE)
V(graph.7)$raster <- list(img.D, img.L)[V(graph.7)$type]
plot(graph.7, vertex.shape = "raster", vertex.label = NA, vertex.size = 16, vertex.size2 = 16, edge.width = 2)
I cannot figure it out. It is not throwing an error, but rather just plotting some stock image (a red node surrounded by yellow nodes) at every node. Any help would be greatly appreciated. Thanks!