Shortest paths network error zero length

Hi everyone! I have a problem in computing the shortest paths in a network in R. In particular, I have randomized a two-mode network with the following code:

``````library(tnet)
n1 <- 441
n2 <- 210
ptie <- nrow(data_network)/(n1*n2)
random_data <- rg_tm(ni=n1, np=n2,ties=ptie, seed = 1000)
random_network = network(random_data,matrix.type="edgelist",directed = TRUE)
``````

But then when I try to compute the shortest paths with the following code:

``````distance_tm(random_network, projection.method="sum")
``````

I have the following error:

``````Error in if (ncol(net) == 3) { : the argument has lenght zero
``````

Does anyone know why? The same happens with the following real two-mode network:

``````structure(list(owner = c("ABBA JEANS MINING Sprl", "ABBA JEANS MINING Sprl", "ACACIA Sprl", "ACACIA Sprl", "ACACIA Sprl", "ACACIA Sprl", "AFRICAN ENGINEERING CORPORATE Sprl",  "AFRICAN ENGINEERING CORPORATE Sprl", "AFRICAN ENGINEERING CORPORATE Sprl",  "AFRICAN MINERALS (Barbados) Ltd Sprl"), armed_band = c("Mayi Mayi Militia (Bakata Katanga)",  "Militia (Elements)", "Batwa Ethnic Militia", "FDD", "Militia (Kamwina Nsapu)",  "RCD-Goma", "Anti-Balaka", "Kuluna Communal Militia", "Militia (Kamwina Nsapu)",  "Mayi Mayi Militia (Bakata Katanga)"), freq = c(1, 1, 1, 1, 4,  1, 1, 1, 1, 1)), row.names = c(NA, -10L), class = c("tbl_df",  "tbl", "data.frame"))
``````

And the same error appears also when I try to compute something different such as:

``````clustering_tm(random_network)
``````

Thank you very much for your attention!

When the argument evaluates to 0, the statement becomes equivalent to `if(0)`. This happens if `net` has fewer than 3 variables.

Thank you very much for reaching out! Actually I have formed the object random_network by using network(). Hence I do not know how to add an extra column to the network object or if I have to do it.

There is no `network` function in `tnet`; therefore, `distance_tm` receives a zero-column argument.

Thank you very much for your time!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.