(function (classes, fdef, mtable):unable to find an inherited method for function ‘X’ for signature

R语言报错

  • 报错原文
  • 问题描述
  • 举例说明解决方案

报错原文

Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘某函数’ for signature ‘“list”’


问题描述

R语言新手往往出现以上报错:
这类报错往往还有个特点就是:第一次写代码的时候没有的,下次重跑代码的时候出现了,暴躁效果拉满。

该错误是因为运行的代码包含两个名字冲突的函数,R无法正确的处理应该使用哪个,所以解决方式是,在函数前面+包:

举例说明解决方案

创建虚拟数据集
dfs <- list(
 age = tibble(name = "John", age = 30),
 sex = tibble(name = c("John", "Mary"), sex = c("M", "F")),
 trt = tibble(name = "Mary", treatment = "A")
)
dfs<-  dfs %>%reduce(full_join,by='name')
#报错:
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘reduce’ for signature ‘"list"#修改为:
dfs<-  dfs %>%purrr::reduce(full_join,by='name')

#运行成功

你可能感兴趣的:(R语言error,r语言)