Re: [R] Still confused about classes

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Thu, 28 Apr 2011 23:16:56 -0700

Hi Russ,

One tool that might help could be ?methods and ?showMethods

For example:
## for S3
methods(class = "Date")
## for S4
showMethods(classes = "Date")

regarding getting the actual year, I would use (though there may be better ways):

format.Date(as.Date("2010-01-01"), format = "%Y")

HTH, Josh

On Thu, Apr 28, 2011 at 11:05 PM, Russ Abbott <russ.abbott_at_gmail.com> wrote:
> Hi,
>
> I'm still confused about how to find out what methods are defined for a
> given class.  For example, I know that
>
>> today <- Sys.Date()
>
> will produce an object of type Date. But I'm not sure what I can do with
> Date objects or how I can find out.
>
>> ?Date
>
>
> refers me to the Date documentation page. But it doesn't tell me how, for
> example, to extract the current year from a date object.
>
> I tried
>
>> year(today)Error: could not find function "year"
>
>
> Is there some other function that does the job? I want a function f such
> that    > f(today)    will return 2011. Perhaps there is no such function.
>  But in general I don't have any confidence that I would know how to find it
> if it existed or that I would know how to assure myself that there was no
> such function.
>
> Thanks.
>
> *-- Russ *
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
R-help_at_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.
Received on Fri 29 Apr 2011 - 06:25:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 07:20:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive