Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • pls share your expected output! Commented Jul 10, 2018 at 6:03
  • @ChirayuChamoli added my expected outcome. Thank you for the feedback. Commented Jul 10, 2018 at 6:12
  • You are not using i anywhere in the loop. Probably , you are trying to do , n[i] <- dist(rbind(df$x[i],df$y[i])). Currently, n is holding only one value at any given time and probably, the entire thing can be replaced without a loop. I am not sure though, as it is not clear to me. Commented Jul 10, 2018 at 6:18
  • what distance calculation are you performing? Commented Jul 10, 2018 at 6:26
  • @Wimpel Euclidean distance. I should have mentioned it earlier sorry. So I could just use sqrt((x[1]-x[2])^2+(y[1]-y[2])^2) kind of formula, but I don't know how to do a loop for that. Any help for this please? Commented Jul 10, 2018 at 6:45