代码之家  ›  专栏  ›  技术社区  ›  Qaswed

为什么使用'attr(x,“class”)`而不是'class(x)`?

  •  0
  • Qaswed  · 技术社区  · 8 年前

    函数 model.frame.default 运行以下代码; is.null(attr(data, "class")) attr is.null(class(data)) ? (这与这里所说的不矛盾吗 Why is names(x) better than attr(x, "names")?

    1 回复  |  直到 8 年前
        1
  •  2
  •   Roland    8 年前

    这些并不等同。比较的输出 class(1) 具有 attr(1, "class")