R中是否有一种方法可以根据另一个df在df上计算新列?

是否可以在R中执行类似的操作(假设df1和df2的行数相同?

if (df1$var1 = 8) df2$var1 = 1.
if (df1$var2 = 9) df2$var2 = 1.