[R] Date as Integer

John Kane jrkrideau at inbox.com
Sat Aug 22 16:03:23 CEST 2015


Do an str() on the data. It looks like your variable is an integer where you probably need a date or a factor.

Would you please include some sample data if possible. See ?dput which is the preferred way for sending sample data. It ensures that the reader is looking at the exact same data that you have on your machine.  

If the data set is large a small, representative sample is find. Something like dput(head(dat1, 100)) is probably fine. Fake data is okay if it is in the same format as the real.  Check with str() before sending.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: shivibhatia at ymail.com
> Sent: Sat, 22 Aug 2015 00:43:05 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] Date as Integer
> 
> Hi All,
> 
> I am using dplyr package and need to find total bills booked grouped on a
> date level however my date is integer.
> In the code below i was trying to change date format from integer.
> However
> it is throwing an error:
> 
> "no applicable method for 'group_by_' applied to an object of class
> "c('integer', 'numeric')"
> 
> ak%>%
>   group_by(as.Date(pickdate),"%y%m%d")%>%
>   summarise(Total=count(waybill))
> 
> Do i need to create a new var first changing the date and then group it
> or
> as.Date will work as i added in dplyr.
> 
> 
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Date-as-Integer-tp4711377.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.



More information about the R-help mailing list