match two columns with two other columns

后端 未结 3 1065
既然无缘
既然无缘 2020-12-10 13:47

I have several rows of data (tab separated). I want to find the row which matches elements from two columns (3rd & 4th) in each row with two other colum

3条回答
  •  春和景丽
    2020-12-10 14:52

    DWin's answer is solid, however with large-ish arrays, typically over 50k or so you'll run into memory issues, as the matrices you're creating are huge.

    I'd do something like:

    match(
      interaction( indat$V3, indat$V10),
      interaction( indat$V4, indat$V11)
    );
    

    Which concatenates all the values of interest into factors and does a match.

    This is a less pure solution, but faster/more manageable.

提交回复
热议问题