I have a data frame that I have created that looks like the image attached (small section for simplicity).
I am trying to find a way to match the two letters (in yellow) to the F1 (blue), B6 (pink), or NOD (green) and create a new column with the name of the assigned match. This data frame is quite large 100 matches to make and 1000+ SNPs to determine.
Any suggestions? I am stumped...
Try using the
dplyr
functionsmutate()
andcase_when()
to create a new column with your matches. You'll probably want to change your column names first, since R doesn't always behave as expected when column names are numbers. Do you have to account for cases where there are zero matches / more than one match?A reply of N/A is sufficient for zero matches (and there will be no more than one match).
Thank you!
Just got to work out how to loop it now :)
Just for others, this did the trick;