S3 및 S4 클래스 규칙을 혼합합니다. is
과 extends
은 S4 클래스를위한 것이지만, 이것들은 구현 된 방식 때문에 S3와 작동합니다. inherits
은 S3 클래스 용으로 작성되었으며 완전한 호환성을 갖춘 S4 개체와 함께 작동하지 않습니다.
inherits
은 class(x)
의 결과를 두 번째 인수에서 지정한 클래스와 효과적으로 비교합니다. 따라서
> class(data.frame())
[1] "data.frame"
은 어디에서도 실패합니다. 이 ?inherits
에서
참고 :
The analogue of ‘inherits’ for formal classes is ‘is’. The two
functions behave consistently with one exception: S4 classes can
have conditional inheritance, with an explicit test. In this
case, ‘is’ will test the condition, but ‘inherits’ ignores all
conditional superclasses.
또 다른 혼란이 객체의 클래스와 객체의 구현입니다. 예, 데이터 프레임은 is.list()
이 말하듯이 목록이지만, R의 S3 클래스 세계에서는 data.frame()
이 "data.frame"
이 아니고 "list"
이 아닙니다.
is(data.frame(),'list')
에 대해서는 해당 특정 클래스가 아닙니다. "list"
따라서 FALSE
입니다. 어떤 is(data.frame())
is(data.frame())
는이 클래스 "data.frame"
합니다 (S4 감지 아닌 S3 의미에서) 연장 클래스를 보여주는 따라서 ?is
Summary of Functions:
‘is’: With two arguments, tests whether ‘object’ can be treated as
from ‘class2’.
With one argument, returns all the super-classes of this
object's class
에서 설명 않는다. 이것은 또한 S4 월드에서의 extends('data.frame','list')
동작을 설명하며, "data.frame"
클래스 은이 "list"
클래스를 확장합니다.
재미있는 정보가있는 또 다른 함수는'getClass ('data.frame')' – eddi