On 16 Sep 2016, at 15:23 , PIKAL Petr <petr.pi...@precheza.cz> wrote:
> Hi Peter > > The devil is in detail > > Data from OP had different format and was transferred to Date object by > as.Date, which results in incorrect values (and NA if not transferred) > df <- data.frame(Date = > c("2013/05/25","2013/05/28","2013/05/31","2013/06/01","2013/06/02", > "2013/06/05","2013/06/07"), Quantity = c(9,1,15,4,5,17,18)) > df$Date<-as.Date(df$Date) > cbind(df, sqldf("select strftime( '%m', Date) from df")) > To be fair, he actually used as.Date(...., "%Y/%m/%d"), so the values were in fact correct. The issue lay in the conversion to integer. I can't figure out how those integers are interpreted, though: > df <- data.frame(date=c(0,1000,2000)) > cbind(df, sqldf("select strftime( '%Y-%m-%d', date) from df")) date strftime( '%Y-%m-%d', date) 1 0 -471-11-24 2 1000 -471-08-20 3 2000 -470-05-16 so the Epoch is nothing sensible and negative years are more than a thousand days?? -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd....@cbs.dk Priv: pda...@gmail.com ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.