r数据处理

R 报错:`by` required, because the data sources have no common variables

两张表没有任何同名列,join 不知道按什么连。

报错原文

Error: `by` required, because the data sources have no common variables.

为什么会报这个错

两张表没有任何同名列,join 不知道按什么连。

怎么解决

显式写 by = c("a" = "b"),或者用 cross_join() 做笛卡尔积。

代码示例

intersect(names(x), names(y))

left_join(x, y, by = c("id" = "code"))

同工具的其他报错

报错解决了,但方法还没搞懂?

报错只是表象。因果推断、面板数据、稳健性检验这些方法背后的逻辑,知识库里按「原理 × 直觉 × 代码」讲清楚了。

进入知识库 →