Combining multiple datasets

I have to combine the datasets provided under as a task for school. I have tried doing so, but getting multiple NA values when I merge them. Can I get any pointers for getting me closer there?

library(data.table)

StoreAttributes <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/26afd5e7-90b1-4301-ac5e-5905b38c4ec2/file_downloaded")
county_crime <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/3691994e-2874-4ee6-b215-12e130c96175/file_downloaded")
county_demographics <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/527e7486-7233-460a-99e0-3529b7cd7d49/file_downloaded")
county_employments <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/846ac757-721e-4fd9-a414-5871f60de093/file_downloaded")
weekly_sales <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/ace0005d-bcfb-46b9-aaff-d69294b11e0c/file_downloaded")
weekly_weather <- fread("https://data.mendeley.com/public-files/datasets/6htjnfs78b/files/1c8b07af-37e6-4ff2-a37c-630cb1d22951/file_downloaded")

either

  1. the data have compatible dimensions and shared order, and thus can be bound rowwise or columns wise (depending on which makes sense)
  2. or the data have matchable keys, and joins can be performed.
  3. or finally if none of the above are true, there is no meaningful way to merge them.

What is the scenario for your case assessed through this lens ?

the data have matchable keys, and joins can be performed

You can code up data.table based joins with the information in this guide :
R data.table Joins. Master operations between data.tables | by Scott Lyden | Analytics Vidhya | Medium
You might find it easier to use tidytable syntax though, if you are willing to add it as an extra dependency.
See here :
Join two data.tables together — left_join. • tidytable (markfairbanks.github.io)

The official documentation provides sufficient examples and the syntax is straightforward:
Introduction to data.table • data.table (rdatatable.gitlab.io)
Creates a join data.table — J • data.table (rdatatable.gitlab.io)
Merge two data.tables — merge • data.table (rdatatable.gitlab.io)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.