Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread arun
HI, The question is not clear.  If it is to get the hours,  strptime(dates, format=%d/%m/%Y %H:%M)$hour # [1]  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  0 #or  as.numeric(format(as.POSIXct(dates, format=%d/%m/%Y %H:%M),%H)) # [1]  0  1  2  3  4  5  6  7  8  9 10 11

[R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
Why am I know getting hours after I convert the date? dates - c('31/12/2013 0:00', '31/12/2013 1:00', '31/12/2013 2:00', '31/12/2013 3:00', '31/12/2013 4:00', '31/12/2013 5:00', '31/12/2013 6:00', '31/12/2013 7:00', '31/12/2013 8:00', '31/12/2013 9:00', '31/12/2013 10:00', '31/12/2013

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread Luke Miller
as.Date produces Dates only, with no time information, even if you try to supply it with hours + minutes. For dates+times, use as.POSIXct() or as.POSIXlt() in place of as.Date(). POSIXct produces a numeric value for the number of seconds since your specified origin time (usually 1970-01-01

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread MacQueen, Don
Because a Date object represents calendar dates, and calendar dates don't have hours. Use as.POSIXct() instead of as.Date() (and spend a little more time with the documentation for as.Date) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread arun
Hi, You could use:  strptime(dates, format=%d/%m/%Y %H:%M)[1:2] #[1] 2013-12-31 00:00:00 2013-12-31 01:00:00  as.POSIXlt(dates, format=%d/%m/%Y %H:%M)[1:2] #[1] 2013-12-31 00:00:00 2013-12-31 01:00:00 A.K. Thanks. as.POSIXct works for the most part. The only problem is part of data I'm working

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
This function returns date/times without timezone strptime(dates,format=%d/%m/%Y %H:%M) -- View this message in context: http://r.789695.n4.nabble.com/why-is-as-date-function-not-working-for-me-dd-mm--h-mm-tp4684874p4684895.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
Thanks. as.POSIXct works for the most part. The only problem is part of data I'm working has it's own time zone. Is there a way to not have a time zone displayed? My times do not change with Daylight saving. -- View this message in context:

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread Jeff Newmiller
You must deal with identifying the time zone. I have found that setting TZ environment variable appropriately for the data before converting character values to POSIXct gives me the best results. This is actually easier for standard-time-only data than for data with daylight savings time