Create column based on another dataframe

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

I have what seems a simple requirement, but I can't seem to achieve the desired result. My dataframes are rather large, so I will just give a screenshot:

What I want is: if ps2c$ps == present2$pn then ps2c$sf == present2$sf.

If it is not clear, for every ps2c$ps there is a present2$pn (present2 is just the mean data).

回答1:

You don't supply test data, but something like the following might work:

ps2c$sf <- present2$sf[match(ps2c$ps, present2$pn)] 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!