This is daylight savings time issue.
Use chron or set your TZ environment variable to a standard-time-only timezone (or don't enter nonexistent time values for the timezone in which you wish to compute).
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Adrienne Wootten <amwootte@ncsu.edu> wrote:

R-listers,

I have noticed several posts on issues with difftime producing NA's
but they have been for older versions of R. Here's the issue
associated with difftime that I am dealing with in R 2.12.2.

> preciptime = strptime("01/10/2007 14:00",format="%m/%d/%Y %H:%M")
> class(preciptime)
[1] "POSIXlt" "POSIXt"
> # Now using difftime, this is what happens
>

> difftime(strptime("03/11/2007 01:00",format="%m/%d/%Y %H:%M"),preciptime,units="hours")
Time difference of 1427 hours

> difftime(strptime("03/11/2007 02:00",format="%m/%d/%Y %H:%M"),preciptime,units="hours")
Time difference of NA hours

> difftime(strptime("03/11/2007 03:00",format="%m/%d/%Y %H:%M"),preciptime,units="hours")
Time difference of 1428 hours

This doesn't make sense to me since both times used in difftime are in
the same format after using strptime, but the differences are coming
out wrong. It should be 1427, 1428, and 1429, so I'm confused as to
how to fix this. The idea with the program is to compute the time in
hours since last rainfall, so everything gets thrown off with this
producing NA's. For reference, Operating system is Windows 7
Enterprise, R is version 2.12.2 (64-bit), any guidance is appreciated.

Thanks in advance!

A
-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University

_____________________________________________

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.


	[[alternative HTML version deleted]]

