Error in seq_len(no) : argument must be coercible to non-negative integer

Hi there,

I have longitudinal network data (3 time points) where not all nodes are present in each period. I also created attribute lists for each of the three edgelist to make sure I have only the nodes from each edgelist in the respective attributes data. Since I would like to match edgelist and nodes attributes by ID, I made sure the first column in the attributes data is ID and the edgelist is set up as ego_id, alter_id, weight.

This is a sample of my edgelist:

edgelist_time1 <- tibble::tribble(
              ~ego_id, ~alter_id, ~weight,
                   7L,        8L,      7L,
                   7L,        9L,      7L,
                   7L,      113L,      1L,
                   7L,      114L,      1L,
                   7L,      115L,      1L,
                   8L,        7L,      7L,
                   8L,        9L,      4L,
                   8L,       11L,      6L,
                   8L,       12L,      6L,
                   8L,       13L,      6L,
                   8L,       15L,      4L,
                   9L,        7L,      4L
              )
head(edgelist_time1)
#> # A tibble: 6 x 3
#>   ego_id alter_id weight
#>    <int>    <int>  <int>
#> 1      7        8        7
#> 2      7        9        7
#> 3      7      113      1
#> 4      7      114      1
#> 5      7      115      1
#> 6      8        7         7

I created an igraph object from an edgelist which worked.

contact_time1_net <- graph_from_data_frame(d=edgelist_time1, directed = T)

contact_time1_net

output:

IGRAPH a75a5df DNW- 137 360 -- 
+ attr: name (v/c), weight (e/n)
+ edges from a75a5df (vertex names):
  [1] 7 ->8   7 ->9   7 ->113 7 ->114 7 ->115 8 ->7   8 ->9   8 ->11  8 ->12  8 ->13  8 ->15  9 ->7   9 ->8  
 [14] 9 ->10  9 ->11  9 ->12  9 ->13  9 ->14  9 ->15  10->11  10->12  10->113 10->116 10->117 11->7   11->9  
 [27] 11->10  11->12  11->13  11->14  11->15  12->10  12->11  12->13  12->14  12->124 13->14  13->15  13->117
 [40] 13->125 13->191 14->7   14->9   14->11  14->12  14->13  14->15  16->10  16->11  16->12  16->13  16->14 
 [53] 17->19  17->20  17->101 17->122 17->127 18->16  18->17  18->20  18->113 18->118 19->16  19->17  19->102
 [66] 19->117 19->121 19->122 19->123 20->16  20->17  20->18  20->19  20->118 21->17  21->22  21->44  21->119
 [79] 21->120 22->17  22->21  22->120 22->128 22->129 22->130 24->25  24->26  24->27  24->28  24->29  24->30 
 [92] 24->31  24->46  24->132 25->24  25->27  25->28  25->29  25->31  25->82  25->138 25->147 26->24  26->25 
+ ... omitted several edges

However, whenever I try to assign my vertex/node attributes it gives me the error: Error in seq_len(no) : argument must be coercible to non-negative integer.

contact_time1_net <- graph_from_data_frame(d=edgelist_time1, directed = T, vertices=attributes_time1)

contact_time1_net

This is a sample of my attributes data:

attributes_time1 <- tibble::tribble(
                      ~ID, ~plant_t1,    ~name_t1, ~level_t1, ~participation_t1, ~response_time_min_t1,
                       7L,        1L,    "Daniel",        4L,                1L,                   35L,
                       8L,        1L,      "Luca",        4L,                1L,                   21L,
                       9L,        1L,     "Dejan",        4L,                1L,                   36L,
                      10L,        1L,   "Melissa",        4L,                1L,                   30L,
                      11L,        1L,    "Markus",        4L,                1L,                   14L,
                      12L,        1L,      "Sven",        4L,                1L,                   36L,
                      13L,        1L, "christian",        4L,                1L,                   23L,
                      14L,        1L,     "Milan",        4L,                1L,                   21L
                      )
head(attributes_time1)
#> # A tibble: 6 x 6
#>      ID plant_t1 name_t1 level_t1 participation_t1 response_time_min_t1
#>   <int>    <int> <chr>      <int>            <int>                <int>
#> 1     7        1 Daniel         4                1                   35
#> 2     8        1 Luca           4                1                   21
#> 3     9        1 Dejan          4                1                   36
#> 4    10        1 Melissa        4                1                   30
#> 5    11        1 Markus         4                1                   14
#> 6    12        1 Sven           4                1                   36

output:

IGRAPH 15f9f29 DNW- 187 360 -- + attr: name (v/c), plant_t1 (v/n), name_t1 (v/c), last_name_t1 (v/c), level_t1 (v/n), | participation_t1 (v/n), response_time_min_t1 (v/n), interest_tech_t1 (v/n), technological_skill_t1 | (v/n), training_t1 (v/n), training_app_t1 (v/n), awareness_t1 (v/n), availability_t1 (v/n), | availability_app_year_t1 (v/n), startusage_app_year_t1 (v/n), future_usage_t1 (v/n), | future_usage_frequency_t1 (v/n), current_usage_frequency_t1 (v/n), usage_machinestatus_t1 (v/n), | usage_measurementreport_t1 (v/n), usage_measuredvalues_t1 (v/n), push_machinestatus_t1 (v/n), | push_measurementreport_t1 (v/n), push_measuredvalues_t1 (v/n), ease_usage_t1 (v/n), | seed_usage_1_t1 (v/n), seed_usage_2_t1 (v/n), seed_usage_3_t1 (v/n), scaling_t1 (v/n), | sentimement_t1 (v/n), management_importance_t1 (v/n), gender_t1 (v/n), age_t1 (v/n), educ_t1 | (v/n), occup_t1 (v/n), management_2sition_t1 (v/n), language_1_t1 (v/n), language_2_t1 (v/n), | language_3_t1 (v/n), device_system_1_t1 (v/n), Covid_control_t1 (v/n), covid_changes_t1 (v/n), | covid_changes_2_t1 (v/n), weight (e/n) + edges from 15f9f29 (vertex names):

Traceback:
error in seq_len(no) : argument must be coercible to non-negative integer

17. eval(x$expr, data, x$env)

16. eval(x$expr, data, x$env)

15. FUN(X[[i]], ...)

14. lapply(x, lazy_eval, data = data)

13. lazy_eval(args, data = c(attrs, .inc = .inc, inc = inc, adj = adj, .from = .from, from = from, .to = .to, to = to, .igraph.from = list(.Call(C_R_igraph_mybracket, graph, 3L)[as.numeric(x)]), .igraph.to = list(.Call(C_R_igraph_mybracket, graph, 4L)[as.numeric(x)]), .igraph.graph = list(graph), ...

12. `[.igraph.es`(edges, seq_len(no))

11. edges[seq_len(no)]

10. na.omit(es)

9. as.igraph.es(graph, na.omit(es))

8. ends(x, edges[seq_len(no)], names = names)

7. x("width", no = can_max)

6. head_print_callback(x, max_lines, header, footer, omitted_footer, ...)

5. head_print(fun, max_lines = max.lines)

4. .print.edges.compressed.limit(x, edges, names, max.lines)

3. .print.edges.compressed(x, names = names, max.lines = max.lines - head_lines)

2. print.igraph(x)

1. (function (x, ...) UseMethod("print"))(x)

Perhaps, anyone has an idea what the problem could be.

Many thanks in advance!

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Hi! Thanks! I made the adjustment. Let me know if I can provide anything else.

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.