R - 多条件循环

时间:2017-10-05 19:02:48

标签: r data-modeling

在运行以下示例场景的R代码时需要帮助:

Set_1 = data.frame(Enc=c(23345,23345,23349,23349,23349,23354,23367,23367,23372,23372,23382),
                   CPT = c("97110","97140","99396","36415","99000","99203O","73030","99024","99213O","36415","81002"),
                   Paid_Status = c("Paid","Non Paid","Paid","Non Paid","Non Paid","Paid","Paid","Non Paid","Paid","Non Paid","Non Paid"))

Set_2 = data.frame(Main_CPT = c("26010","26010","26010","26010","26025","26025","26025","26025","26025","26025","26034",26034","26034","26034","26034"),
                   Child_CPT = c("01810",01995","0213T","0216T","64490","64491","64492","64493","64494","64495","64530","69990","99148","99149","99150"))

从第一个数据开始,我需要从每个编号中验证Enc明智的行CPTPaid_Status。其中一个CPTMain_CPT,其他CPTChild_CPT,详细信息可与第二个数据集进行比较。

现在,我想看看与第二个数据集的CPT匹配的Main_CPT并且支付特定CPT的状态的第1个新列数据设置为" P"在该行中,那个Enc的剩余CPT应该与第二个数据集的Child CPT匹配,并且第一个数据集的新列中的相应行应该是" A"。

0 个答案:

没有答案