0

I want to delete vertices with the code below but have this error message:

Error in delete.vertices(n_all, V(n_all)[degree(n_all) == 0]) : delete.vertices requires an argument of class network.

I follow some suggestions from here (remove unconnected nodes R igraph or ggnet) but still not successful. Any one having solutions would be much appreciated.

require(igraph)
meta <- read.csv("vil35_meta.csv", header = TRUE, as.is = TRUE)
n_all <- graph.adjacency(as.matrix(all), mode = "undirected", weighted = TRUE)
V(n_all)$caste <- meta$castesubcaste
V(n_all)$religion <- meta$hohreligion
V(n_all)$rooms <- meta$room_no

n_all <- delete.vertices(n_all, V(n_all)[degree(n_all)==0])
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
  • Please show a minimal reproducible example that demonstrates the problem. https://stackoverflow.com/help/minimal-reproducible-example – Szabolcs Nov 04 '22 at 08:13
  • 1
    I am not able to reproduce this problem, so we really need a complete minimal example to proceed. – Szabolcs Nov 06 '22 at 12:20
  • 2
    Your code works flawlessly on my system (Windows, igraph_1.3.4). Could you please provide the first 10 lines of the csv file? Or as many as needed to demonstrate the problem? – clp Nov 07 '22 at 15:13
  • 1
    Greetings! Usually it is helpful to provide a minimally reproducible dataset for questions here so people can troubleshoot your problems (rather than a table or screenshot for example). One way of doing this is by using the `dput` function on the data you are using and pasting the output into your question. You can find out how to use it here: https://youtu.be/3EID3P1oisg – Shawn Hemelstrand Nov 16 '22 at 07:18

0 Answers0