Displaying 20 results from an estimated 50000 matches similar to: "Casting "character" to "Date" using the "as" function"
2004 May 24
1
as.matrix.data.frame() in R 1.9.0 converts to character when it should (?) convert to numeric
Conversion of a data frame to a matrix using as.matrix() when a
column of the data frame is POSIXt and all other columns are numeric
has changed in R 1.9.0 from R 1.8.1. The new behavior issues a
warning message and converts to a character matrix. In R 1.8.1, such
an object was converted to a numeric matrix.
Here is an example.
#### R 1.9.0 ####
> foo <- data.frame(
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
2012 Nov 05
1
Dates as POSIXt
When I try to do linear interpolation between financial contracts with maturities on different dates in different months I have come across some behavior I haven't seen before.
I have a data frame in R which is loaded from an access database so I can't provide a working example. It was loaded using this code:
> dbPath <- "H:/pathToDB/DB.mdb"
> channel <-
2009 Nov 19
0
Wishlist: In documentation, say that `+.Date`(Date, difftime) should be called directly or remove 'or an object of class "difftime"' (PR#14072)
Full_Name: Suharto Anggono
Version: 2.8.1
OS: Windows
Submission from: (NULL) (125.161.134.206)
About PR#14067, now I understand why (Date + difftime) does not use '+.Date'.
But, before I understand, it was surprising. The surprise is also reflected in
the post "Problem with +(POSIXt, difftime) dispatching -- WAS: How to create
sequence of constant time interval" in R-help
Suggestions for improvement as regards `as` methods, and a call for consistency in `as.Date` methods
2016 Jan 27
0
Suggestions for improvement as regards `as` methods, and a call for consistency in `as.Date` methods
Good evening all,
This topic is gone into at a bit more length at my related Stack Overflow
question here:
http://stackoverflow.com/questions/34647674/why-do-as-methods-remove-vector-names-and-is-there-a-way-around-it
There are two lingering issues despite the abundant insight received at SO,
namely:
1) _Why_ do as methods remove their arguments' names attribute?
This is a fact which is
2010 Feb 01
1
Error with cut.POSIXt and daylight savings time switchover dates
The following code:
cut(as.POSIXct("2009-11-01 04:00:00", tz="America/Los_Angeles"), "1 day")
gives the error:
Error in seq.int(0, to - from, by) : 'to' must be finite
This is related to November 1st, 2009 being the switchover date from daylight savings time to standard time in the America/Los_Angeles time zone. In particular, in cut.POSIXt, the starting
2002 Jul 02
1
POSIX formats have problems with NA (PR#1732)
# pure replication code at end
> # These work
>
> Sys.time() + NA
[1] NA
> as.POSIXlt(Sys.time(), "GMT") + NA
[1] NA
>
> class(Sys.time() + NA)
[1] "POSIXt" "POSIXct"
> class(as.POSIXlt(Sys.time(), "GMT") + NA)
[1] "POSIXt" "POSIXct"
>
> x <- Sys.time() + NA
> y <- as.POSIXlt(Sys.time(),
2006 Sep 25
0
na.encode in format for Date and POSIXt classes
Hello!
na.encode does not have any effect on format of NA values of Date and
POSIXct (POSIXlt?) "atomic" classes in a data.frame. Here is the example
(the same in R 2.3.1 and 2.5.0 (2006-09-19 r39409)):
testData <- data.frame(num=c(NA, 2.6),
int=c(1, NA),
fac=factor(c(NA, "abc")),
cha=c("a",
2002 May 12
0
{round,trunc}.POSIXt and daylight savings time (PR#1543)
I have found what looks like a small problem in trunc.POSIXt()
involving the transition to/from standard time and daylight savings
time. Assuming my assessment is correct, I have a potential solution
to offer.
If a time in daylight savings time is rounded such that the rounded
value is on the other side of the transition, the isdst element does
not get changed accordingly. I have tested only
2011 Mar 23
0
suggestions re trunc.POSIXt
Dear all,
I hope this is a right place to post this; r-help might be appropriate
but it looks like I'm suggesting a change in base package, so I
decided to post here. (+ Apologies if that has been changed recently
-- the version I'm using is R.2.12.2 on Windows.)
I've noticed an unexpected behavior of trunc.POSIXt:
foo <- seq(as.POSIXct( "2009-10-23 22:00:00"),
2008 Apr 10
1
ISOdate/ISOdatetime performance suggestions, other date/time questions
Dear list:
working with date/times I have come across a problem that ISOdate and
ISOdatetime are too slow on large vectors of data. I was surprised just
until I looked at the implementation and the man page: "ISOdatetime and
ISOdate are convenience wrappers for strptime". In other terms, they
convert data to character representation first in order to create a
POSIXlt object that is then
2004 Oct 05
2
correct my method of estimating mean of two POSIXlt data frames
Hello, I searched the archives but could not come to a solution. I
have to two columns of information
t_start_cdt looks like:
> t_start_cdt[1:4]
[1] "2003-07-09 11:02:25" "2003-07-09 11:10:25" "2003-07-09 11:30:25"
[4] "2003-07-09 12:00:25"
> class(t_start_cdt)
[1] "POSIXt" "POSIXlt"
t_end_cdt looks like:
> t_end_cdt[1:4]
2002 May 03
1
Daylight savings time and conversion to POSIXt (arghh!)
I have asked this question before, and received some suggestions for
work-arounds that get the job done--and they are much appreciated.
But I would still like to find out if I'm missing something, and
whether there is a direct way using POSIXt functions (as.POSIXct,
as.POSIXlt, strptime, in particular).
I have environmental data collected once per minute. Here is a subset
of 3 input
2008 Jul 03
1
'as.Date' conversion of classes POSIX*t (problem/feature)?
Hi,
I'm working with objects of classes "Date","POSIXlt" and "POSIXct" and still
having some Date/Time-related concepts unclear. In the documentation of
"as.Date" one can find:
"The 'as.Date' methods accept ... '"POSIXlt"' and '"POSIXct"'. (The last are
converted to days by ignoring the time after
2013 Mar 26
0
as.Date.POSIXct
Would it make sense for as.Date.POSIXct to not assume tz="UTC" if the
POSIXct object has a valid tzone attribute? Current behavior may be
confusing in certain cases, for example:
> (d <- structure(1090450800, tzone="Europe/Berlin",
+ class=c("POSIXct","POSIXt")))
[1] "2004-07-22 01:00:00 CEST"
> as.Date(d)
[1] "2004-07-21"
>
2002 May 21
1
I() fails on objects of class POSIXct (PR#1587)
Although the documentation is somewhat sketchy, I() can be used to create
objects of class AsIs:
> I("a")
[1] "a"
attr(,"class")
[1] "AsIs" "character"
> I(4)
[1] 4
attr(,"class")
[1] "AsIs" "numeric"
> I(4 + 0i)
[1] 4+0i
attr(,"class")
[1] "AsIs" "complex"
>
This
2002 May 17
0
round.POSIXt gets certain values wrong
For certain values, round.POSIXt(tm,'day') does not round to midnight
as documented. The reason is that trunc.POSIXt() does not adjust the
value of the isdst element. Assuming my assessment of the reason is
correct, I have a potential solution to offer. Additional discussion
is in bug report #1543.
-Don
> x <- c(as.POSIXct('2001-4-1 3:15'),as.POSIXct('2001-5-2
2005 Apr 30
0
(PR#7826) Re: ... print.POSIXct .. infinite recursion
Thank you, Jskud.
I can reproduce your problem, though not the
seg.fault, see below
>>>>> "Jskud" == Jskud <Jskud@Jskud.com>
>>>>> on Sat, 30 Apr 2005 09:04:03 +0200 (CEST) writes:
Jskud> In attempting to build R using rpmbuild --rebuild
Jskud> R-2.1.0-0.fdr.2.fc3.src.rpm
Jskud> on a fairly up-to-date RedHat 9 system (that
2009 Mar 04
2
patch for axis.POSIXct (related to timezones)
I am finding that axis.POSIXct uses the local timezone for deciding where to
put tic marks, even if the data being plotted are in another time zone. The
solution is to use attr() to copy from the 'x' (provided as an argument) to
the 'z' (used for the 'at' locations).
I have pasted my proposed solution in section 1 below (as a diff). Then, in
section 2, I'll put some
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,