我正在尝试使用包中的函数从中删除列,当没有列与我的搜索模式匹配时,遇到错误。使用标准的数据集并导入合适的软件包,library(dplyr) library(data.table) select(data.table(iris), -matches("^Petal")) # returns a table with three columns: Sepal.Length, Sepal.Width, Species select(data.table(iris), -matches("^ER[[:digit:]]+$")) # displays error message: # Error in data.table::setnames(out, names(vars)) : x has no column names 有没有办法删除与给定正则表达式匹配的任何列(如果存在),否则保持表格不变?