# Help: Error message "length of NULL cannot be changed"

**URL:** <https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397>\
**Category:** Usage\
**Tags:** R\
**Created:** [1 August 2020 12:41 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397 "2020-08-01T12:41:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldie](https://avatars.discourse-cdn.com/v4/letter/g/e36b37/32.png) [@goldie](https://igraph.discourse.group/u/goldie)\
**Post date:** [1 August 2020 12:41 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397/1 "2020-08-01T12:41:02Z")

</div>

When trying to generate colors or change the weight of edges when using igraph I’m generating the error “length of NULL cannot be changed.”

Specifically when running these codes:

```r
    colrs <- c("skyblue", "orchid2", "peachpuff")
    V(net)$color <- colrs[V(net)$source]

```

I get:

```auto
Warning message:
In length(vattrs[[name]]) <- vc : length of NULL cannot be changed

```

When I run the code:

```r
E(net)$width <- E(net)$weight/6

```

I get the same error. Has anyone gotten similar errors and know what to do with them in this context? Thank you

---

<div class="post-metadata">

**Author:** ![vtraag](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/vtraag/32/38_2.png) [@vtraag](https://igraph.discourse.group/u/vtraag)\
**Post date:** [20 August 2020 08:23 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397/2 "2020-08-20T08:23:16Z")

</div>

I am unable reproduce your problem. Please post a minimal working example of your problem. Perhaps it would then be possible to identify the problem.

---

<div class="post-metadata">

**Author:** ![bimaben](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/bimaben/32/887_2.png) [@bimaben](https://igraph.discourse.group/u/bimaben)\
**Post date:** [13 December 2022 22:36 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397/3 "2022-12-13T22:36:50Z")

</div>

Were you able to identify a solution to this issue?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [14 December 2022 06:15 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397/4 "2022-12-14T06:15:55Z")

</div>

@bimaben As stated above, in order to help, we need a minimal example that demonstrates the problem. See here for guidance: [How to create a Minimal, Reproducible Example - Help Center - Stack Overflow](https://stackoverflow.com/help/minimal-reproducible-example)

---

<div class="post-metadata">

**Author:** ![KeesP](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@KeesP](https://igraph.discourse.group/u/KeesP)\
**Post date:** [14 December 2022 13:56 UTC](https://igraph.discourse.group/t/help-error-message-length-of-null-cannot-be-changed/397/5 "2022-12-14T13:56:08Z")

</div>

Try.

```auto
net <- graph_from_literal(A-B, A-C)
colrs <- c("skyblue", "orchid2", "peachpuff") 
V(net)$color <- colrs[V(net)$source]
V(net)$color <- character(0)
E(net)$width <- E(net)$weight/6
E(net)$width <- numeric(0)

```

These error messages occur because `V(g)$color` and `E(g)$weight` do not exists and dependent expressions are coerced to `character(0)` and `numeric(0)` respectively.
