我有一个看似简单的要求,但我似乎无法达到预期的效果.我的数据帧相当大,所以我只是给出一个截图:
我想要的是:if ps2c$ps == present2$pn then ps2c$sf == present2$sf.
如果不清楚,每个ps2c$ps都有一个present2$pn(present2只是平均数据).
And*_*rie 10
您不提供测试数据,但以下内容可能有效:
ps2c$sf <- present2$sf[match(ps2c$ps, present2$pn)]
Run Code Online (Sandbox Code Playgroud)