I have three dataframes:
cities_df
, which contains the name of a city amongst other fields
cities_df <- data.frame(
city_name = c("London", "Newcastle Upon Tyne", "Gateshead"),
city_population = c(8673713L, 289835L, 120046L),
city_area = c(1572L, 114L, NA)
)
states_df
, which contains the name of a state amongst other fields
states_df <- data.frame(
state_name = c("Greater London", "Tyne and Wear"),
state_population = c(123, 456)
)
dictionary_df
, which contains the whole list of cities and their corresponding state.
dictionary_df <- data.frame(
city_name = c("London", "Newcastle Upon Tyne", "Gateshead"),
state = c("Greater London", "Tyne and Wear", "Tyne and Wear")
)
Is there any way to relate/link cities_df
and states_df
dataframes so I can have an easy way to get all the cities' fields that belong to a certain state?