Hi Patrick, On Fri, Mar 18, 2011 at 12:17 PM, Patrick Connolly <p_conno...@slingshot.co.nz> wrote: > On Wed, 16-Mar-2011 at 07:58PM -0700, Joshua Wiley wrote: > |> ## A small example is always nice > |> dat <- ts(1:12, frequency = 12, > |> start = c(1998, 1), end = c(2010, 12)) > |> > |> ## Achim and Gabor's wonderful package > |> require(zoo) > |> ## now just convert to a date > |> as.Date(dat) > > I'm impressed with that approach but can't see how it works. > > The object dat is of class "ts". How does having the zoo package in > the search path influence how as.Date() works? I didn't notice in the > help file for as.Data anything that mentioned zoo and ts objects.
It is just one of those things you would have to know or find (e.g., searching via findFn() from package "sos" or the like). zoo defines an S3 method for as.Date(). To see this: require(zoo) methods(as.Date) ## show current methods for as.Date ## now if you want to see exactly *how* it works: getAnywhere("as.Date.ts") ## getAnywhere is needed because it is in zoo's namespace Cheers, Josh > > TIA > > -- > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. > ___ Patrick Connolly > {~._.~} Great minds discuss ideas > _( Y )_ Average minds discuss events > (:_~*~_:) Small minds discuss people > (_)-(_) ..... Eleanor Roosevelt > > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ ______________________________________________ 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.