I have two dataframes: x and y columns are the coordinates of the respectives households and hospitals. My expected result is obtain two new columns in the household dataframe. One column must show which is the nearest hospital of each household the other one must illustrate the euclidean distance of the nearest hospital of each household.
household<-c("a","b","c","d")
x_household<-c(2,2.1,2.05,1.99)
y_household<-c(20,20.1,19.9,20.2)
hh<-data.frame(household,x_household,y_household)
hh
hospital<-c("f","j")
x_hospital<-c(2.2,2.4)
y_hospital<-c(19,21)
hospital<-data.frame(hospital,x_hospital,y_hospital)
hospital