当使用 geom_smooth 绘制最佳拟合线时,我得到:`stat_smooth()`: invalid 'x' type in 'x || y' in R

When using geom_smooth to plot a best fit line I get: `stat_smooth()`: invalid 'x' type in 'x || y' in R

我目前正在尝试创建具有最佳拟合线的散点图。

df %>% 
  ggplot(aes(y = d_emp, x=d_gdp)) +
  geom_point() +
  geom_smooth(method = "lm", se = "FALSE")

但是,我不断收到以下错误消息:

Computation failed in stat_smooth(): invalid 'x' type in 'x || y'

散点图效果很好,只有最佳拟合线没有显示(所以 geom_smooth 部分)。

这是我的数据集的样子:

您为布尔参数 se 提供了一个字符串。这应该有效

df %>% 
  ggplot(aes(y = d_emp, x = d_gdp)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE)