Vertex labels in function of its neighbours

I am using igraph to plot a network. Vertex labels shows binary opinions, defined randomly in period t = 0.


network <- set.vertex.attribute(network, "opinion", value = sample(c(1,0), nodes, replace= TRUE))

plot.igraph(network, layout= f, vertex.size=20, vertex.label = V(network)$opinion, vertex.color = V(network)$color, vertex.label.color = "black")

My problem is i need to vary these vertices labels, in period t=1, in a way that vertices labels are influenced by the predominant opinion of its neighbours in the previous period (t = 0). I can do it for a single vertex using the code:

#applying for vertex 1

opinion_t1 <- ifelse(mean(V(network)$opinion[neighbors(network, 1)])>= "0.5", "1", "0"))

How can i apply this for each vertex and plot in the network? I need this to be in the argument vertex.label or is there any other way?

My intention is making a loop to observe opinions varying across time, in function of its neighbours predominant opinions. Then, i intend to use this observations to construct a panel, which will have variables as echo chambers (numbers of triangles), stationary state (if all vertex get the same opinion), etc.