在 R 中使用变量时,允许您避免显式命名数据集的函数是什么?

What is the function that allows you to avoid explicitly naming the dataset when using a variable in R?

我知道有这个功能,过去也用过,但似乎记不起或找不到了。

基本上我正在尝试执行以下操作:

data(mtcars)

missing_function(mtcars)

lm(mpg ~ cyl)

其中“missing_function()”允许我使用 mtcars 数据集中的变量而无需使用“$”。例如:“mpg”而不是“mtcars$mpg”。

虽然通常不受欢迎,attach 会为您做到这一点

R> attach(mtcars)
R> mpg
 [1] 21 21 23 21 19 18 14 24 23 19 18 16 17 15 10 10 15 32 30 34 22 16 15 13 19 27 26 30
[29] 16 20 15 21
R>