Hi, I am trying to create a loop using "for" to calculate the minimum distances between points (in coordinates Latitude - Longitude) in two dataframes

In my case I have a dataframe1 with more than 1,000 points and another (dataframe2) with more than 10,000 points, and I need to assign closest points in dataframe2 to each point in dataframe1

The distance between two points is calculated using the formula:

This is an example of dataframes with coordinates:

```
coordinates1 <- data.frame("X1"=c(70,10,50), "Y1"=c(20,5,60))
coordinates2 <- data.frame("X2"=c(1,2,45,7,8,5,4,13,3,6), "Y2"=c(2,5,36,4,3,2,6,27,9,8))
```

Could someone help me to solve it?

Thanks in advance

Javi (from Madrid, Spain)