I have the following data frame (dat), in which each row is uniquely identified by a person's name.
Name Distance Driven Distance From Home
John Smith 123 km 115 km
Michael Jones 15 km 8 km
Eric Stevens 777 miles 725 miles
Brian McGee 1029 km 1029 km
Dave Baker 8 miles 8 miles
I have a second data frame (dat2), also uniquely identified by Name, that includes only a portion of the names in the initial data set, as well as some new names. However, the data in each row (other than name and the column names) does not exist.
Name Distance Driven Distance From Home
John Smith
Derek Thompson
Eric Stevens
Dave Baker
I'm looking to create a new data frame which includes:
- observations that were in both the original data frame (dat) and in the second data frame
- observations that were only in the second data set
- All the data in the rows from the initial data set
As such, I really just want to eliminate names that were only present first data set and not the other. I would thus like the two data frames above to produce:
Name Distance Driven Distance From Home
John Smith 120 km 115 km
Derek Thompson
Eric Stevens 777 miles 725 miles
Dave Baker
I hope that makes sense. Thanks in advance.