First of all I would like to say thanks to everyone for sharing valuable
information, now I can able to do that if date column datatype is “Factor”
but by default the date column datatype is “POSIXct” in R ,so whenever I
want apply stfrtime function with sqldf package ,do I need to convert the
date datatype to factor ??? or is there any alternative way?
On Fri, Sep 16, 2016 at 9:08 PM, peter dalgaard <pda...@gmail.com> wrote:
> 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/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
Manohar Reddy P
[[alternative HTML version deleted]]
Remail@example.com mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.