Problem with merging two data frames in R with different columns

Viewed 38

I have a filtered dataframe Id that are as following.

ID    Bonus
35    25.54
36    24.32
37    43.23
38    24.43
39    34.21
40    23.12

I want to merge Id with the below dataframe City

ID   City       Lat_Long
35   Paris      list(67.14.6552, 67.33539)...
36   Oslo       list(70.24.5215, 62.53525)...
37   Berlin     list(62.54.3533, 64.63438)...
38   Rome       list(67.34.2458, 68.13539)...
39   London     list(65.54.6215, 69.23139)...
40   Barcelona  list(61.54.3055, 62.73520)...
41   Vilnius    list(64.54.6051, 61.23535)...
#With 500 more rows

So it is going to look like this Id_city

ID   City       Lat_Long                           Bonus
35   Paris      list(67.14.6552, 67.33539)...      25.54
36   Oslo       list(70.24.5215, 62.53525)...      24.32
37   Berlin     list(62.54.3533, 64.63438)...      43.23
38   Rome       list(67.34.2458, 68.13539)...      24.43
39   London     list(65.54.6215, 69.23139)...      34.21
40   Barcelona  list(61.54.3055, 62.73520)...      23.12

I have tried the join function Id_city <- inner_join(Id, City, by = "ID") which should work. However, I get error Column Lat_long is a sfc_MULTIPOLYGON/sfc object. What can I do to solve this?

1 Answers

It was a beginner mistake by me.

The tibble didn't understood sfc_multipolyn/sfc object.

To solve it I needed to install library(sf).

Related