I have a data frame (jan2020) of bicycle services, where the origin and destination stations are mentioned as follows:
Origen_Id Destiny_Id #data frame A
2 52
93 10
In another data frame (stations), I have the station's Id, name, latitude and longitude, and other information.
id Nombre Latitude Longitude
2 Name1 20.666378 -103.34882
3 Name2 20.667228 -103.366
4 Name3 20.66769 -103.368252
I would like to create a data frame like this,
Origen_Id Destiny_Id Lat_Orig Lon_Orig Lat_Des Long_Des
2 52 20.666378 -103.34882 some number some number
I tried to do it with a for-loop but it's not efficient, another thought was to
jan2020$Index_Id <- match(jan2020$Origen_Id, stations$id)
However, this only tells me the index of the station in the data frame stations, and I'm not sure how to create a new column with the information I need.