r - Why using `attr(x, "class")` instead of `class(x)`? -
the function model.frame.default
runs following code; is.null(attr(data, "class"))
. question is, why using attr
in case? wouldn't more straight forward use is.null(class(data))
? (and doesn't contradict said here: why names(x) better attr(x, "names")?)
these not equivalent. compare output of class(1)
attr(1, "class")
. latter returns explicit s3 classes, former implicit classes.
Comments
Post a Comment