R - Merging and aligning two CSVs using common values in multiple columns
0
0
Entering edit mode
2.2 years ago
Michael ▴ 10

I currently have two .csv files that look like this:

File 1:

enter image description here

File 2:

enter image description here

I would like to merge and align the two .csvs such that the result each row of File 1 is aligned by its "result" cell, against any of the three "outcome" columns in File 2, leaving blanks or "NA"s if there are no similarities.

Ideally, would look like this:

enter image description here

Any help would be very much appreciated.

csv R • 523 views
ADD COMMENT
2
Entering edit mode

Please don't post images of the data.

  1. Convert File 2 to long format and store all outcome values in a column titled Outcome.
  2. Join File 1 and long formatted File2 on Result (from File1) and Outcome ( from long formatted File2, a column in which all outcomes are stored)
  3. Convert output (from step2) from long format to wide format.
  4. Format table using packages such as kable
ADD REPLY
0
Entering edit mode

I have created a new post with the data now shown as code instead of images.

ADD REPLY

Login before adding your answer.

Traffic: 1758 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6