Reputation: 3879
The function model.frame.default
runs the following code; is.null(attr(data, "class"))
. My question is, why using attr
in this case? Wouldn't it be more straight forward to use is.null(class(data))
? (And doesn't it contradict to what is said here: Why is names(x) better than attr(x, "names")?)
Upvotes: 0
Views: 47
Reputation: 132949
These are not equivalent. Compare the output of class(1)
with attr(1, "class")
. The latter returns only explicit S3 classes, the former also implicit classes.
Upvotes: 2