I have two data frames,
df1,
chr start end
3676 chr1 793962 95298066
2913 chr20 13200929 13200929
and
df2
chr pos strand fit
cg15903280 chr1 793962 - -0.42120400
cg16619049 chr1 805541 + -0.05317789
and I needed to combine those two data frames based on the two columns, chr and start from df1 and chr and pos from df2. And I tried using subset as,
head(subset(df, chr %in% df2$chr & start %in% wanted_cgs$pos) )
But I dont get all columns from df2 in the resulting rows. Any suggestions would be great.
In the end, I need the row names from df2 to be appended to the resulting data frame. Like this,
chr pos strand fitted
cg15903280 chr1 793962 - -0.42120400
cg16619049 chr1 805541 + -0.05317789