[R] Problem with ddply in the plyr-package: surprising output of a date-column

Christoph Jäckel christoph.jaeckel at wi.tum.de
Mon Apr 25 22:17:17 CEST 2011


Hi together,

thank you so much for your help! The problem was indeed the
strptime-function. Replacing that with as.Date solves the problem,
both in the example I provided and in my actual data set.

I think this is a lesson for me to not use types I'm not really
familiar with (POSIXlt in this case).

Thanks again!

Christoph

On Mon, Apr 25, 2011 at 10:07 PM, Hadley Wickham <hadley at rice.edu> wrote:
>
> > If you need plyr for other tasks you ought to use a different
> > class for your date data (or wait until plyr can deal with
> > POSIXlt objects).
>
> How do you get POSIXlt objects into a data frame?
>
> > df <- data.frame(x = as.POSIXlt(as.Date(c("2008-01-01"))))
> > str(df)
> 'data.frame':   1 obs. of  1 variable:
>  $ x: POSIXct, format: "2008-01-01"
>
> > df <- data.frame(x = I(as.POSIXlt(as.Date(c("2008-01-01")))))
> > str(df)
> 'data.frame':   1 obs. of  1 variable:
>  $ x: AsIs, format: "0"
>
> Hadley
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/



--
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Christoph Jäckel (Dipl.-Kfm.)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Research Assistant

Chair for Financial Management and Capital Markets | Lehrstuhl für
Finanzmanagement und Kapitalmärkte

TUM School of Management | Technische Universität München

Arcisstr. 21 | D-80333 München | Germany

Mailto: christoph.jaeckel at wi.tum.de | Web: www.fm.wi.tum.de

Phone: +49 89 289 25482 | Fax: +49 89 289 25488



Head of Chair:

Univ.-Prof. Dr. Christoph Kaserer

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

E-Mail Disclaimer

Der Inhalt dieser E-Mail ist vertraulich und ausschliesslich
fuer den bezeichneten Adressaten bestimmt. Wenn Sie nicht
der vorgesehene Adressat dieser E-Mail oder dessen Vertreter
sein sollten, so beachten Sie bitte, dass jede Form der
Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder
Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir
bitten Sie, sich in diesem Fall mit dem Absender der E-Mail
in Verbindung zu setzen.

The information contained in this email is confidential....{{dropped:11}}



More information about the R-help mailing list