Re: [R] sapply and Date objects

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun 21 May 2006 - 01:15:18 EST

>From ?sapply we see that sapply requires a list or
atomic vector. If its not a list then looking at the first few two lines of sapply we see it tries to convert the first arg to a list using as.list. Note that using your dt:

> as.list(dt)

[[1]]
[1] -5813

so try this instead:

sapply(list(dt), as.character)

On 5/20/06, Fernando Saldanha <fsaldan1@gmail.com> wrote:
> This is probably a dumb question, but I cannot figure it out. Why does
> this happen?
>
> dt <- as.Date("1954-02-01")
> > as.character(dt)
> [1] "1954-02-01"
> > sapply(c(dt), as.character)
> [1] "-5813"
>
> Thanks.
>
> FS
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun May 21 01:22:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 21 May 2006 - 02:10:12 EST.

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