-2

I have two tables: one with airport codes and Airport dataframe with iata_code and name. I want to replace the airport codes to full names. I think to use iata_code column in Airport dataframe to find the vector of row indices in Airport, using %in% opreator. Using the vector of indices, extract the name column in the relevant airport codes and save the vector of full names to my table. here is my table:my table

and here is airports table: enter image description here

thank you for your help

  • 1
    According to this forums guidelines you shouldn't post images of code or data, but add a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). Adding a MRE and an example of the desired output (in code form, not tables and pictures) makes it much easier for others to find and test a answer to your question. That way you can help others to help you! P.S. Here is [a good overview on how to ask a good question](https://stackoverflow.com/help/how-to-ask) – dario Feb 12 '21 at 12:59

1 Answers1

0

Join two data.frames:

new_df <- merge(first_table, airports_table, by.x="dest", by.y="iata_code")
dario
  • 6,415
  • 2
  • 12
  • 26