Joining dataframes and introducing NA into rowa

I am trying to join two data frames together. I would like to join the DFs by the shared variables Device number & Date and fill in some differing variables with NA. This is because although the dates in the two data frames are similar one data frame has dates that begin earlier than the other. Ideally, I would just like to fill in these 'missing' dates and fill in the new rows with NA. After this I plan to find the difference in another shared variable which is Time. I have got this far:

Join <- inner_join(IDTimeSorotiDogGPS1, OrderedD051XX, by = c("deviceNr"))

I have also tried:

Join <- inner_join(IDTimeSorotiDogGPS1, OrderedD051XX, by = c("deviceNr", "Date"))

However, when joining using both deviceNr and Date, it changed the values of some of the variables in the second data frame, most notably it changed the time values.

Any help would be much appreciated! TIA

See the FAQ: How to do a minimal reproducible example reprex for beginners. Without a better understanding of the objects all I can suggest is to create a third data frame with the missing dates and the same variables populated with NA and rbind the data frame with the later beginning dates to it before attempting the join.

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.