On Wed, 14 Jul 2010, Meissner, Tony (DFW) wrote:

I have a dataframe that contains time values in the form of yyyy-mm-dd hh:mm i.e. 2010-07-14 13:00. When I convert this to numeric via tvec <- as.numeric(Time) I get a number that is in seconds. So far so good. When I then divide the numeric value by the number of seconds in a day eg tvec/(60*60*24) I only get integer values and not fraction of a day which is what I want.

You need to show us a reproducible example (as the posting guide asked). Clearly

Time <- "2010-07-14 13:00"
as.numeric(Time)

fails to give anything useful, so your description is not correct.
OTOH,

as.numeric(as.POSIXct(Time))/(60*60*24)
[1] 14804.5

does give fractional days.

What do you actually want? Note that not all days are 24 hours long in most timezones, so if you are doing this to get the time of day you need to be aware that you get it in UTC (which is why 13:00 is half a in my timezone is halfway through a day).


What do I need to do to get decimal days?

Tsch??
Tony Meissner
Principal Scientist (Monitoring)
Resources Monitoring Group
Science, Monitoring and Information Division
Department for Water
"Imagine" ?
*(ph) (08) 8595 2209
*(mob) 0401 124 971
*(fax) (08) 8595 2232
* 28 Vaughan Terrace, Berri SA 5343
       PO Box 240, Berri SA 5343
       DX 51103

Is that in some unstated country?  You wrote to a worldwide audience.

--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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.

Reply via email to