Displaying 20 results from an estimated 20000 matches similar to: "POSIXct vs Dates"
2003 Nov 11
4
HMisc describe -- error with dates
Hello,
I am trying to use HMisc describe on a data frame. I have specified certain
variables as dates using, for example:
df1$aidsdate <- dates(aidsdate,format="day.mon.year", origin=c(month = 1,
day = 1, year = 1960))
When I use describe on the dataframe I get this error:
Error in Ops.dates(weights, x) : * not defined for chron objects
Has anyone had this problem? I had
2003 Dec 04
5
Processing calendar dates with R
I am a beginner in R with a background in SAS.
Are there built-in R methods of reading dates for calculating elapsed days
between two calendar dates? If so, are there any examples I can browse?
Thanks in anticipation.
John Byrne.
Lecturer in Information Systems.
Australian Catholic University.
2004 Mar 05
3
as.POSIXct problem
Hi all,
I'm having difficulty converting a 'dates' object to a POSIXct object:
testDATES<-c(35947,35971,36004,36008,36053,36066)
testDATES<-chron(dates=testDATES, format = c(dates = "m/d/y"),
origin=c(month = 12, day = 30, year = 1899))
>[1] 06/01/98 06/25/98 07/28/98 08/01/98 09/15/98 09/28/98
> as.POSIXct(testDATES)
[1] NA NA NA NA NA NA
2003 Jul 31
4
timezones
I have some questions and comments on timezones.
Problem 1.
# get current time in current time zone
> (now <- Sys.time())
[1] "2003-07-29 18:23:58 Eastern Daylight Time"
# convert this to GMT
> (now.gmt <- as.POSIXlt(now,tz="GMT"))
[1] "2003-07-29 22:23:58 GMT"
# take difference
> now-now.gmt
Time difference of -5 hours
Note that the difference
2003 Sep 17
3
Using POSIX?t rather than "chron" or "date"
The problem with POSIXt is that you must consider timezones
and daylight vs. standard time issues even if you don't want
to. This violates modularity (viz. your routines becomes coupled
to unrelated information) and leads to subtle errors where different
routines are assuming different time zones.
The problem is that the time, date, day of the week, month, etc.
of a date depend on its
2003 Nov 12
3
Chron, as.POSIXct problem
Dear R list,
I noticed the following 'problem' when changing the format of dates
created with seq.dates() (from the Chron library) using as.POSIXct()
(R 1.8.0 on OSX 10.2.8):
> datesTest<-seq.dates(from="10/01/1952", length=3, by="days");
> datesTest
[1] 10/01/52 10/02/52 10/03/52
# Now changing the format to show year as 1952.
>
2003 Nov 19
5
ISOdate returns incorrect date?
Dear all,
I have found the following (for me) incomprehensible behaviour of
ISOdate (POSIXct):
> ISOdate(1900,6,16)
[1] "1900-06-15 14:00:00 Westeurop?ische Sommerzeit"
> ISOdate(1950,6,16)
[1] "1950-06-16 14:00:00 Westeurop?ische Sommerzeit"
Note that in the first case I get the 15th of June back, not the 16th as
I would have expected!
This happened under R-1.7.1 on
2007 Jul 31
1
POSIXct Formating Error (PR#9819)
To Whom It May Concern:
The following appears to be a bug in the way POSIXct dates are formated.
The example is forced, but occurs naturally when importing Excel type dates
(where fractional part is fraction of a day) and small rounding errors
result.
As shown, looking at the POSIXct class, it looks as if both times are
16:11:03 (truncation)
Looking at as.numeric.POSIXct, it looks as if
2009 Jul 20
1
Problem with as.POSIXct on dates object
Dear R-helpers,
I have a problem converting an object made with the 'chron' function
to a POSIXct object:
# Make date based on DOY
dat <- chron(dates=232, origin.=c(month=1, day=1, year=2008))
dat
#[1] 08/20/08
# Converting to POSIXct uses current timezone (Sydney):
as.POSIXct(dat)
#[1] "2008-08-20 10:00:00 EST"
# Setting GMT timezone has no effect?
as.POSIXct(dat,
2004 Jul 07
1
question about seq.dates from chron vs. as.POSIXct
Dear R People:
Here is an interesting question:
>library(chron)
>xt <- seq.dates(from="01/01/2004",by="days",length=5)
>xt
[1] 01/01/04 01/02/04 01/03/04 01/04/04 01/05/04
>
#Fine so far
>as.POSIXct(xt)
[1] "2003-12-31 18:00:00 Central Standard Time"
[2] "2004-01-01 18:00:00 Central Standard Time"
[3] "2004-01-02 18:00:00 Central
2003 Oct 17
7
datetime data and plotting
If I take the following simple data:
YEAR MONTH DAY WEIGHT.KG
2003 10 6 1.2
2003 10 12 1.2
2003 10 16 1.3
and format the date data and plot it:
dates <- strptime(paste(DAY,MONTH,YEAR),"%d%m%Y")
plot(c(min(dates),max(dates)),c(0,max(WEIGHT.KG)),
xlab="Date",ylab="Weight (kg)",type="n")
lines(dates,WEIGHT.KG)
points(dates,WEIGHT.KG)
I find that the
2006 Sep 01
3
Date conversion with as.POSIXct and as.POSIXlt (PR#9196)
Full_Name: Erich Neuwirth
Version: 2.3.1
OS: Windows XP, Linux
Submission from: (NULL) (131.130.135.167)
Converting Sys.Date() to a POSIX compliant time type in different ways
produces inconsistent results:
> Sys.date()
[1] "2006-09-01"
> as.POSIXct(Sys.Date())
[1] "2006-09-01 02:00:00 CEST"
> as.POSIXlt(Sys.Date())
[1] "2006-09-01"
>
2003 Dec 15
3
Julian Dates
Hi,
I'm a bit confused how julian() works. If I understand right, it returns
the number of days since the origin.
I have a vector:
> SLDATX[1:10]
[1] "1986-01-06" "1986-01-17" "1986-02-02" "1986-02-04"
[5] "1986-02-04" "1986-02-21" "1986-03-06" "1986-03-25"
[9] "1986-04-06"
2006 Feb 21
3
Number of Days Between Dates: Incorrect Results For Date Calucations.
In some cases, incorrect results are produced by the code below intended to
calculate the number of days between 2 dates. The year in question was a
leap year.
Note the results for 2004-04-04 and 2004-04-05 are the same! They should be
37 and 38 respectively.
> as.integer(as.POSIXct("2004-04-02") - as.POSIXct("2004-02-27"))
[1] 35
>
2005 May 11
2
time zones, daylight saving etc.
Hi, I have a whole bunch of data, which looks like:
15/03/2003 10:20 1
15/03/2003 10:21 0
15/03/2003 12:02 0
16/03/2003 06:10 0
16/03/2003 06:20 0.5
16/03/2003 06:30 0
16/03/2003 06:40 0
16/03/2003 06:50 0
18/03/2003 20:10 0.5
etc. (times given on a 24 hour clock)
and goes on for years. I have some code:
2016 Apr 04
2
Understanding POSIXct creation on different OSes.
Hello,
Following Dirk's post here: https://github.com/Rdatatable/data.table/issues/1619
we would like to clarify if this is the right behaviour, and if so,
the rationale behind it.
Here's the summary (thanks to Dirk and Joshua):
Sys.setenv("TZ"="America/Chicago")
dates = as.Date("2016-03-02") + (0:3)*7 # four Wednesdays
# [1] "2016-03-02"
2011 Mar 08
1
Date arithmetic coerces POSIXlt to POSIXct?
Hi. This feels like a bug to me, or at least an undocumented feature,
but I thought I'd see what people here thought of it. Consider a POSIXlt
object like this one:
> a <- as.POSIXlt ("2011-01-23 12:45:45")
> class (a)
[1] "POSIXlt" "POSIXt"
Fine. Now, if I do some arithmetic on that object, the result is
converted to POSIXct.
> class (a
2007 Nov 01
1
daylight saving / time zone issues with as.POSIXlt/as.POSIXct (PR#10392)
Running under Windows XP 64 bit, as.POSIXlt()/as.POSIXct() seem
to think that US time zones (EST5EDT, MST7MDT) switched from daylight
savings back to standard time on Oct 28, 2007, whereas the switch
is actually on Sun Nov 04, 2007.
Examples:
> Sys.timezone()
[1] "Mountain Daylight Time"
> as.POSIXct("2007-10-30 12:38:47")
[1] "2007-10-30 12:38:47 Mountain
2003 Dec 04
4
bug in as.POSIXct ?
I think that there is a bug in the as.POSIXct function on Windows.
Here is what I get on Win2000, Pentium III machine in R 1.8.1.
> dd1 <- ISOdatetime(2003, 10, 26, 0, 59, 59)
> dd2 <- ISOdatetime(2003, 10, 26, 1, 0, 0)
> dd2 - dd1
Time difference of 1.000278 hours
Now, the 26th of October was the day that change to the standard time
occurred, so I suspect that this has
2005 Feb 18
1
creating POSIXct dates in C
I'm trying to generate POSIXct times in a call to a C function.
However, I'm having trouble generating times with the proper offset from
UTC.
Can anyone offer any help with this issue?
I've looked at R-2.0.1/src/main/datetime.c, but I was not able to find
an example that I could easily pull from that file.
Thanks in advance,
Whit
Here is my example in C:
#include <stdio.h>