Error in mutate_impl(.data, dots) : Evaluation error: Argument 2 must be type character

Error in mutate_impl(.data, dots) : Evaluation error: Argument 2 must be type character

问题

我想对两个数据帧进行完全连接,以便来自观察结果的一些数据只有一行和一些包含数据的向量被复制到另一个数据帧中所有观察结果的多行。这两个数据帧匹配 "site" 和 "lib."

library(data.table); library(magrittr); library(dplyr) 
df1<-structure(list(lib = c(10118L, 10118L, 10118L, 10104L, 10104L, 10104L                      ), site = c("yanglingshaanxi", "yanglingshaanxi", "yanglingshaanxi",                                   "tianjin", "tianjin", "tianjin"), y = c(1.896017347, 0.919531829,                                                                           1.150194405, 2.164771575, 1.060472222, 1.372680891), yr = c("1991", "1992", "1993", "2009", "2010",                                                                                                                                       "2012")), .Names = c(                                                                                                                                            "lib", "site", "y","yr"), class = c("data.table", "data.frame"), row.names = c(NA,                                                                                                                                                                                                                      -6L))
df2<-structure(list(yr = c(NA_integer_, NA_integer_), lib = c(10104L,                                                          10118L), site = c("tianjin", "yanglingshaanxi"), y = c(NA_real_,                                                                                                                 NA_real_)), .Names = c("yr", "lib", "site", "y"), class = "data.frame", row.names = c(10695L,                                                                                                                                                                                                       10698L))

y<-full_join(df1, df2,by=c("site","lib")) %>%
  mutate(
    yr=coalesce(yr.x,yr.y), #there are way more vectors that i'm actually coalescing than this it that matters
    y=coalesce(y.x,y.y)
    )  %>% 
  select(-c(
    yr.x,yr.y,
    y.x,y.y,
    lib  ))

如何消除此错误?

Error in mutate_impl(.data, dots) : 
  Evaluation error: Argument 2 must be type integer, not character.
In addition: Warning message:
package ‘bindrcpp’ was built under R version 3.3.3 

我可以发誓自从我几个月前使用它以来我没有碰过它 - 我现在加载包裹的顺序有误吗? "Argument 2" 指的是什么?

目前接近

尝试先加载plyr,然后加载dplyr;然后尝试仅加载 dplyr。尝试查看 。试图在 ??mutate 中找到错误消息指的是什么,试图通过

查看来源
> getAnywhere(mutate)
A single object matching ‘mutate’ was found
It was found in the following places
  package:dplyr
  namespace:dplyr
with value

function (.data, ...) 
{
    UseMethod("mutate")
}

"Argument 2" 显然只是指在一个数据框中重新制作并合并的向量。我开始认为可能是这种情况,所以我通过蛮力找到了各自数据帧中整数和字符的向量,只需沿着合并的 ~30 个向量的列表向下搜索​​并注释掉它们,找出哪些向量使代码再次工作时他们是 "off"。 因此,这修复了它:在有问题的数据框中将 "yr" 更改为整数:

df1$yr<-as.integer(as.character(df1$yr))