Dynamically build call for lookup multiple columns

前端 未结 3 1574
南旧
南旧 2020-11-27 20:19

How can I dynamically lookup multiple fields and add by reference using character vector variable as argument. In below case I want to lookup two columns and get ri

3条回答
  •  臣服心动
    2020-11-27 21:06

    Here's the crude way:

    myj <- parse(text=paste0("`:=`(",paste0(select,"=i.",select,collapse=","),")"))
    ID[JN,eval(myj)]
    #    id meta value
    # 1:  1    1     x
    # 2:  2    1     v
    # 3:  3    1     f
    

提交回复
热议问题