# excel file
refugee <- read_excel("../00_data/mydata.xlsx") %>% janitor::clean_names()
Primary keys include the_number_of_refugees, the_number_of_asylum_seekers, the_number_of_returned_refugees, the_number_of_internally_displaced, the_number_of_others_of_concern_to_unhcr, the_numbero_of_host_community_members, the_number_of_stateless_persons
Divide it using dplyr::select in a way the two have a common variable, which you could use to join the two.
refugee_1half <- refugee %>% select(the_year_of_data_collection:country_of_asylum_name)
refugee_2half <- refugee %>% select(country_of_asylum_name:the_numbero_of_host_community_members)
left_join(refugee_1half, refugee_2half)
## Joining with `by = join_by(country_of_asylum_name)`
## Warning in left_join(refugee_1half, refugee_2half): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
## "many-to-many"` to silence this warning.
## # A tibble: 56,803,257 × 16
## the_year_of_data_collection country_of_origin_name country_of_origin_unhcr_…¹
## <dbl> <chr> <chr>
## 1 2010 Afghanistan AFG
## 2 2010 Afghanistan AFG
## 3 2010 Afghanistan AFG
## 4 2010 Afghanistan AFG
## 5 2010 Afghanistan AFG
## 6 2010 Afghanistan AFG
## 7 2010 Afghanistan AFG
## 8 2010 Afghanistan AFG
## 9 2010 Afghanistan AFG
## 10 2010 Afghanistan AFG
## # ℹ 56,803,247 more rows
## # ℹ abbreviated name: ¹country_of_origin_unhcr_code
## # ℹ 13 more variables: country_of_origin_iso_code <chr>,
## # country_of_asylum_name <chr>, country_of_asylum_unhcr_code <chr>,
## # country_of_asylum_iso_code <chr>, the_number_of_refugees <dbl>,
## # the_number_of_asylum_seekers <dbl>, the_number_of_returned_refugees <dbl>,
## # the_number_of_internally_displaced_persons <dbl>, …