错误(函数(类,fdef,mtable)):无法为签名“'''spec_tbl_df"找到函数"select"的继承方法

错误(函数(类,fdef,mtable)):无法为签名“'''spec_tbl_df

问题描述:

我的项目中出现了此错误代码.

I am having this error code appear on in my project.

奇怪的是,我正在使用的这段代码在今天早些时候运行良好.但是,由于我安装了R的更新,因此在运行它时会收到此消息.

the strange thing is, the piece of code I am using was working perfectly earlier today. However, since I installed an update for R I am now getting this message when running it.

df1 <- df %>% select(Month, Longitude, Latitude, Type)

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘select’ for signature ‘"spec_tbl_df"’

该代码仅用于创建仅包含选定列的新数据框.

The code was used simply to create a new data frame with only the selected columns.

任何帮助将不胜感激!

最近发布了R的新版本:4.0.0.

A new version of R has recently been released: 4.0.0.

进行了一些重大更改,参见此处列表.该文档说,这可能会破坏某些基于R 3.6.*行为的方法.也许类spec_tbl_df的方法依赖于已更改的内容.

There has been some major changes, see here for a list. The documentation says that this might have broken some methods that were based on R 3.6.* behavior. Maybe the method for the class spec_tbl_df was relying on something that changed.

这不仅仅是确定的答案,也许有些用户会为您提供更好的答案

That's a clue more than a definitive answer, maybe some users will give you a better one

给出 issue 此处,类spec_tbl_df的对象的基本R select方法和dplyr::select方法之间存在冲突.在这种情况下,最简单的解决方案是通过使用dplyr::select语法来确保使用dplyr命名空间.

Given the issue here, it looks like there exists a conflict between the base R select method and dplyr::select method for objects of class spec_tbl_df. In that case, the easiest solution is to ensure you use dplyr namespace by using the dplyr::select syntax.