You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:R中使用dplyr的filter函数时报‘object dose not found’错误

解决dplyr筛选时"object dose not found"错误

问题原因

你仅安装了dplyr包,但未加载它。Base R自带的filter()函数功能和dplyr的版本完全不同,直接调用filter()时,R不会自动使用dplyr的实现,因此无法识别你在筛选条件中使用的列名语法。

修复方案

方案1:加载dplyr包(推荐)

在代码开头添加library(dplyr),确保R调用的是dplyr的filter()函数:

library(dplyr)
data("ToothGrowth")
View(ToothGrowth)
filtered_ToothG <- filter(ToothGrowth, dose == 0.5)
View(filtered_ToothG)

方案2:使用命名空间调用(无需加载包)

如果不想加载整个dplyr包,可以直接指定使用dplyr的filter函数:

data("ToothGrowth")
View(ToothGrowth)
filtered_ToothG <- dplyr::filter(ToothGrowth, dose == 0.5)
View(filtered_ToothG)

内容的提问来源于stack exchange,提问作者Lewis21-10

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 21:05:37