I want to draw a set of nodes with different flags of the countries the nodes belongs to. In a component there are 20-30 nodes and they are from different countries, and I am trying to draw them with the flags of their countries.
I tried to assign the flags as a node attribute and plot them with igraph "raster" option. I am able to draw in this way 1 flag for all the nodes, but when I try to give the attribute different values for different flags, it crashes
#The name of the network is "prueba"
library(png)
library(igraph)
#There is no problem with the import of the flags to the environment
img1 <- readPNG("1.png")
img2 <- readPNG("2.png")
# If i want 1 flag for all, there is no problem. This code works perfectly
V(prueba)$raster <- replicate(vcount(prueba), img1, simplify=FALSE)
#But if I want to apply them conditioned to the "residence" it crashes, and shouldn't
V(prueba)[V(prueba)$residence== "1"]$raster <- replicate(vcount(prueba), img1, simplify=FALSE)
V(prueba)[V(prueba)$residence== "2"]$raster <- replicate(vcount(prueba), img2, simplify=FALSE)