I need help on a code, I don't understand the reason why it stops working

I am working on a code that helps me determine the minimum distance between two nodes if I have a succession of them, in my code when the weight is an integer it works perfectly, but if I put a decimal a part works and then it marks me $<- .data.frame(tmp`, "i", value = 5) : replacement has 1 row, data has 0 and I can't find the error, could you help me?

My code is the following
The part where my code fails is this:
p[r]<- min(Aristas[Aristas$From==i,"Peso"]+p[r-1])

    Aristas[Aristas$From==i&Aristas$Peso==p[r]-p[r-1],]$Estado<-1
    Aristas[Aristas$From==i&Aristas$Peso==p[r]-p[r-1],]$Color<-colorarista
    Aristas[Aristas$From==i&Aristas$Peso==p[r]-p[r-1],]$PesoAc<-p[r]

Edges contains the data of "From", "To","Peso","PesoAc","Estado" ,"i", "Color"
ii is where the union of the nodes comes from

the data is as follows
|From|To|Peso|PesoAc|Estado|i|Color|

1 2 1.485 0 0 0 black
2 3 2.485 0 0 0 black
3 4 3.485 0 0 0 black
4 5 4.485 0 0 0 black
5 6 5.485 0 0 0 black
6 7 6.485 0 0 0 black
7 8 7.485 0 0 0black

Can you refer to the reprex (https://reprex.tidyverse.org/) criteria for the forum users to help you.

1 Like

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.