Displaying 20 results from an estimated 10000 matches similar to: "Suspicious behaviour of sort on POSIXct vectors in R-2.3.0 and R-2.3.1"
2003 May 11
1
lines(aline, type = 'b', col = "blue) does not work for POSIXct plot.
Hello,
x <- ISOdate(2003, 4, 1:30) # POSIXct vector
y <-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30)
aline <- c(30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1)
plot(x, y, xaxt = 'n', main = 'Number of Stuff for the Project, April 2003', xlab = 'Report Time', ylab = 'Number of
2004 Oct 18
2
答复: How to draw x-axis time label.
Thank you for helping me!
I try the "pretty" funtion to select the x-axis position value.Then I use the "format" funtion.
xax.pos <- pretty(as.numeric(x$x.name))
format(xax.pos,'%d %b %y')
> xax.pos
[1] 1091600000 1091800000 1092000000 1092200000 1092400000 1092600000 1092800000
[8] 1093000000
There are something wrong. I found the xax.pos has been changed to
2006 Oct 04
2
integers to POSIXct
What is the recommended way to convert/coerce and integer to a POSIXct
please?
d <- as.POSIXct(Sys.Date())
i <- as.integer(d)
as.POSIXct(i)
Error in as.POSIXct.default(i) : do not know how to convert 'i' to class
"POSIXlt"
This appears to be the behaviour in 2.3.1 and 2.4.0 on windows XP.
I have tried searching on this and found as.Date.integer in package zoo
which
2011 Jul 15
2
Odd behaviour of as.POSIXct
Dear all,
how come the first loop in the below fails, but the second performs as
expected?
days <- as.Date( c("2000-01-01", "2000-01-02") )
for(day in days)
{
as.POSIXct(day)
}
for( n in 1:length(days) )
{
show(as.POSIXct(days[n]))
}
Many thanks, Jo
[[alternative HTML version deleted]]
2008 Feb 05
1
Inconsistent lattice scales$x$at,label behaviour for POSIXct
I have encountered the following behaviour in lattice in 2.6.1 (and
2.4.0) which differs depending upon the type you use. I believe the
numeric behaviour to be correct, and the POSIXct behaviour to be in
error.
When the x data and x axis in a lattice graph are POSIXct, and when
using scales$x$at and scales$x$labels to add custom labels:
If the first visible at value is not the first
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"
>
2019 May 01
3
anyNA() performance on vectors of POSIXct
Inside of the anyNA() function, it will use the legacy any(is.na()) code if
x is an OBJECT(). If x is a vector of POSIXct, it will be an OBJECT(), but
it is also TYPEOF(x) == REALSXP. Therefore, it will skip the faster
ITERATE_BY_REGION, which is typically 5x faster in my testing.
Is the OBJECT() condition really necessary, or could it be moved after the
switch() for the individual TYPEOF(x)
2010 Nov 12
1
unexpected behaviour of rbind with dataframe containing POSIXct
Hello list,
here is what I stumbled upon:
1> test <- data.frame(time=as.POSIXct((1:2),origin="2000-1-1"))
1> test
time
1 2000-01-01 00:00:01
2 2000-01-01 00:00:02
1> rbind(test,b=1:2)
Fehler in as.POSIXct.numeric(value) : 'origin' muss angegeben werden
When I try to attach an additional row to a dataframe with a row
containing dates I get the
2017 Mar 09
1
as.POSIXct behaviour
Dear R-devel, I have tested the code below on R v3.3.2 and v3.3.3 on
Mac and Windows.
x <- c("2017-01-01 05:00:02", "2017-01-02 03 :M:00") # note the ? :M?
in 2nd value
as.POSIXct(x)
# [1] "2017-01-01 GMT" "2017-01-02 GMT?
The time info is lost on the first index as well. And it happens *silently*.
On the other hand, if I do:
lapply(x, as.POSIXct)
#?[[1]]
2012 Mar 25
2
Weird POSIXct behaviour
Friends
I have an xts that I wish to access.
Browse[2]> DATA.ba[[p]]["2012-03-20 00:59:57","bid"]
bid
2012-03-20 00:59:57 1.4993
So far so good.
Now putting the index into a variable:
Browse[2]> Time
[1] "2012-03-20 00:59:57 NZDT"
Browse[2]> DATA.ba[[p]][Time, "bid"]
bid
Where has it gone?
Looking closer....
2003 Sep 16
7
Retrieve ... argument values
Dear R users,
I want to retrieve "..." argument values within a function. Here is a small
exmaple:
myfunc <- function(x, ...)
{
if (hasArg(ylim)) a <- ylim
plot(x, ...)
}
x <- rnorm(100)
myfunc(x, ylim=c(-0.5, 0.5))
Error in myfunc(x, ylim = c(-0.5, 0.5)) : Object "ylim" not found
>
I need to retrieve values of "ylim" (if it is defined
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
2008 May 26
2
Strange behaviour of as.POSIXct
Hi:
I do not understand the returned value of NA in the following, which is a simplified version of
my attempt to convert the start column of the data frame AirQual in the SwissAir package.
as.POSIXct(paste('04.04.2004 0',0:3,sep=''),format='%d.%m.%Y %H')
[1] "2004-04-04 00:00:00 EST" "2004-04-04 01:00:00 EST"
[3] NA
2009 Sep 11
1
What determines the unit of POSIXct differences?
Dear All,
what determines if a difference between POSIXct objects gets
expressed in days or seconds?
In the following example, it's sometimes seconds, sometimes days.
as.POSIXct('2009-09-01') - as.POSIXct(NA)
Time difference of NA secs
c(as.POSIXct('2009-09-01'), as.POSIXct(NA)) -
c(as.POSIXct('2009-09-01'), as.POSIXct('2009-08-31'))
Time differences in
2018 May 16
2
Date method of as.POSIXct does not respect tz
R 3.5.0
Is it intended that the Date method of as.POSIXct does not respect the
tz parameter? I suggest changing as.POSIXct.Date to this:
function (x, tz = "", ...)
.POSIXct(unclass(x) * 86400, tz = tz)
Currently, the best workaround seems to be using the character method if
one doesn't want the default timezone (which is often an annoying DST
timezone).
This came up on
2012 Aug 24
1
POSIXct-coerced NA's not considered NA by is.na()
Hello folks,
I found a strangeness while experimenting with POSIXct vectors and
lists. It seems that coerced NA's aren't "real" NAs, at least as
considered by is.na()?
> date_vec = c(as.POSIXct(now()), as.POSIXct(now()+1),NA,"b")
> date_vec
[1] "2012-08-22 15:00:46 COT" "2012-08-22 15:00:47 COT" NA
[4] NA
Warning message:
In
2003 Jun 05
1
question about POSIXct conversion
Hello!
I am trying to compute minimal time on some data like this:
mt<-tapply(mrsh$time1,list(mrsh$var1,mrsh$var2),min):
a b
145 1054800600 1054789800
340 1054804500 1054794600
349 1054820400 1054792800
55 1054800600 1054789200
57 1054814100 1054791000
78 1054822200 1054790400
843
2003 Jan 22
1
Convert numeric value to POSIXct
Hi,
How do I convert a numeric value indicating the time since 1970, back into
a POSIXct class object? I have tried format.POSIXct and as.POSIXct
without success.
For example
> ccc
[1] "1945-01-01 15:00:00 MDT"
> ddd<- as.numeric(ccc);
> ddd
[1] -788842800
> format.POSIXct(ddd)
Error in format.POSIXct(ddd) : wrong class
> as.POSIXct(ddd)
Error in
2012 Jun 15
2
time zones and the chron to POSIXct conversion
Hey R folks,
i found some strange (to me) behaviour with chron to POSIXct conversion.
The two lines of code result in two different results, on ewith the
correct time zone, one without:
library(chron)
as.POSIXct(chron('12/12/2000'), tz = 'UTC')
as.POSIXlt(chron('12/12/2000'), tz = 'UTC')
Only the code below would give me a POSIXct object with the correct time
2012 Jan 19
2
POSIXct value display incorrect for some values
First, the reproducable example, showing how converting from character to
POSIXct to character changes the milliseconds in the first time stamp
though not in the second:
> as.POSIXct('2010-06-03 9:03:58.324')
[1] "2010-06-03 09:03:58.323 PDT"
> as.POSIXct('2010-06-03 9:03:58.325')
[1] "2010-06-03 09:03:58.325 PDT"
This seems to be due to truncation of