[R] S3 vs S4 class

2008-10-07 Thread Terry Therneau
  
  
  A simple example:
temp - as.Date('2001-10-5')
class(temp)
  Date

How do I tell if Date is implemented as an S3 or an S4 class type?
I tried ?class, but didn't see anything obvious.  Functions like inherit() work
equally well with both types (which is a good thing).

  I expect the answer will be obvious - once someone points it out to me.

Terry T

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] S3 vs S4 class

2008-10-07 Thread Duncan Murdoch

On 07/10/2008 10:41 AM, Terry Therneau wrote:
  
  
  A simple example:

temp - as.Date('2001-10-5')
class(temp)
  Date

How do I tell if Date is implemented as an S3 or an S4 class type?
I tried ?class, but didn't see anything obvious.  Functions like inherit() work
equally well with both types (which is a good thing).

  I expect the answer will be obvious - once someone points it out to me.


You could use the isS4 function:

 temp - as.Date('2001-10-5')
 isS4(temp)
[1] FALSE

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.