Hello all, kind regards, I have imported a data.frame from SPSS using "foreign":read.spss but unfortunately it is reading dates in a way neither R nor myself can understand.> book$DATE[1] 13502246400 13443321600 13477795200 13472956800 13501728000 13445395200 13501382400 13502851200 13444185600 13461465600 13457232000 [12] 13458096000 13432435200 13431484800 13495334400 13491964800 13451184000 13490755200 13505616000 13505616000 13502851200 13436928000 [23] 13497408000 13465094400 13484707200 13447555200 13438483200 13464489600 13494816000 13432435200 13455676800 13463884800 13455417600 [34] 13478400000 13504665600 13490150400 13504060800 13471401600 13492915200 13465958400 13445136000 I have looked around the documentation but can find nothing similar there or in Spector's chapter on Dates How do I coerce these to %d%m%Y form? Thank you for your time and patience Ross Dunne ross.dunne at tcd.ie -- View this message in context: http://r.789695.n4.nabble.com/Importing-dates-from-SPSS-file-tp3260293p3260293.html Sent from the R help mailing list archive at Nabble.com.
What do the dates look like in the original file? On Fri, Feb 4, 2011 at 9:47 AM, dunner <ross.dunne at tcd.ie> wrote:> > Hello all, kind regards, > > I have imported a data.frame from SPSS using "foreign":read.spss but > unfortunately it is reading dates in a way neither R nor myself can > understand. > >> book$DATE > ?[1] 13502246400 13443321600 13477795200 13472956800 13501728000 13445395200 > 13501382400 13502851200 13444185600 13461465600 13457232000 > [12] 13458096000 13432435200 13431484800 13495334400 13491964800 13451184000 > 13490755200 13505616000 13505616000 13502851200 13436928000 > [23] 13497408000 13465094400 13484707200 13447555200 13438483200 13464489600 > 13494816000 13432435200 13455676800 13463884800 13455417600 > [34] 13478400000 13504665600 13490150400 13504060800 13471401600 13492915200 > 13465958400 13445136000 > > I have looked around the documentation but can find nothing similar there or > in Spector's chapter on Dates > > How do I coerce these to %d%m%Y form? > > Thank you for your time and patience > > Ross Dunne > ross.dunne at tcd.ie > > > -- > View this message in context: http://r.789695.n4.nabble.com/Importing-dates-from-SPSS-file-tp3260293p3260293.html > Sent from the R help mailing list archive at Nabble.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. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?
On Fri, Feb 4, 2011 at 9:47 AM, dunner <ross.dunne at tcd.ie> wrote:> > Hello all, kind regards, > > I have imported a data.frame from SPSS using "foreign":read.spss but > unfortunately it is reading dates in a way neither R nor myself can > understand. > >> book$DATE > ?[1] 13502246400 13443321600 13477795200 13472956800 13501728000 13445395200 > 13501382400 13502851200 13444185600 13461465600 13457232000 > [12] 13458096000 13432435200 13431484800 13495334400 13491964800 13451184000 > 13490755200 13505616000 13505616000 13502851200 13436928000 > [23] 13497408000 13465094400 13484707200 13447555200 13438483200 13464489600 > 13494816000 13432435200 13455676800 13463884800 13455417600 > [34] 13478400000 13504665600 13490150400 13504060800 13471401600 13492915200 > 13465958400 13445136000 > > I have looked around the documentation but can find nothing similar there or > in Spector's chapter on Dates > > How do I coerce these to %d%m%Y form? > > Thank you for your time and patienceSPSS uses seconds since the beginning of the Gregorian calendar. See the help desk article in R News 4/1 for details: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
as.POSIXlt(book$DATE, origin="1582/10/14") works. The Gregorian calendar was the kicker, thanks to ggrothendieck at gmail.com Ross -- View this message in context: http://r.789695.n4.nabble.com/Importing-dates-from-SPSS-file-tp3260293p3260329.html Sent from the R help mailing list archive at Nabble.com.