I see many people running into a similar issue with great answers but I believe this is an unanswered variation to this question!
I have a graph
g <- reactive(graph_from_dataframe(df))
Now I want to assign a degree
property to this.
V(g())$degree <- degree(g())
This howevers throws the null assignment error but I don't know how to assign it without calling g. I avoided this by assigning the degree property inside an output$... however this heavily violates DRY and leads to double degree calculation.
CodePudding user response:
I guess the following syntax should work
V(g)$degree <- degree(g)
CodePudding user response:
I do not think that reactive(.)
objects take assignments.
Two thoughts:
Use
reactiveVal
:g <- reactiveVal() observeEvent(df, { newg <- graph_from_dataframe(df) V(newg)$degree <- degree(new) g(newg) })
Handle the
$degree
assignment in the originalreactive
:g <- reactive({ newg <- graph_from_dataframe(df) V(newg)$degree <- degree(newg) newg })