Displaying 20 results from an estimated 7000 matches similar to: "strptime and "impossible" dates"
2003 Mar 05
1
printing POSIXct values in table labels
Hi,
I think that there is something that I am misunderstanding in creating tables
using dates that are of class POSIXct. Consider:
> x <- data.frame(date = as.POSIXct(strptime(c(rep("2002-10-17", 4), rep("1999-12-08", 2)), format = "%Y-%m-%d")))
> x
date
1 2002-10-17
2 2002-10-17
3 2002-10-17
4 2002-10-17
5 1999-12-08
6 1999-12-08
> table(x$date)
2001 May 22
1
dates
I am just starting to play with R. What is the recommended manner for dealing
with dates? In particular, should I be using the "chron" or the "date" package
or working with some of the facilities in base R like strptime?
My needs are very limitted. I have variables that, in S+ 6.0, I treat as
timeDate objects. I rarely need to do more than read in the information from
text
2002 Apr 30
3
rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
Hi,
In 1.4.1, I was able to create extra "empty" rows in a dataframe as so:
> x <- data.frame(a = letters[1:3], b = 1:3)
> x
a b
1 a 1
2 b 2
3 c 3
> x[4,]
a b
NA NA NA
> rbind(x, x[4,])
a b
1 a 1
2 b 2
3 c 3
NA NA NA
> R.version
_
platform sparc-sun-solaris2.6
arch sparc
os solaris2.6
2002 May 08
3
Suggestions for poor man's parallel processing
Almost all of the heavy crunching I do in R is like:
> for(i in long.list){
+ do.something(i)
+ }
> collect.results()
Since all the invocations of do.something are independent of one another, there
is no reason that I can't run them in parallel. Since my machine has four
processors, a natural way to do this is to divide up long.list into 4 pieces
and then start 4 jobs, each of which
2008 May 30
3
Strptime
Hi
This code should explain what I'm trying to do
> strptime("30-Jan-08", "%d-%b-%y")
[1] "2008-01-30"
>
> format(strptime("30-Jan-08", "%d-%b-%y") , "%b-%y")
[1] "Jan-08"
>
> strptime(format(strptime("30-Jan-08", "%d-%b-%y") , "%b-%y") ,
"%b-%y")
[1] NA
I have a
2007 Jan 08
1
Does strptime(...,tz="GMT") do anything?
Hi All
In trying to correlate some tide gauge data I need to deal with varying
timezones. From the documentation on strptime, it seemed that the tz
variable might have some effect on the conversion, but I'm not seeing an
effect.
> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="PST")+0
[1] "2006-12-01 01:02:00 EST"
>
2007 Jun 12
1
Can strptime handle milliseconds or AM/PM?
I'm trying to proess date/time fields from files that were given to me to
analyze.
Any clues what I'm doing wrong with strptime? This seems to fail the same
way under Linux or Windows.
For ?strptime would it make sense to explain %OS3 somewhere besides the
Examples?
> # Why does %OS3 work here?
> format(Sys.time(), "%H:%M:%S")
[1] "16:45:19"
>
2011 Jul 06
1
trouble parsing a date using strptime()
Hi,
I am having a trouble parsing dates using strptime() that I get in the
format of year and week number. The data looks like this "201127" which
means year 2011 and week 27. I would like to graph this using ggplot but
then I get a gap between 201054 and 201101 so I thought I would just easily
convert it.
I tried to use strptime and as.Date and the format string of %Y%W but it
seems
2010 Jan 06
2
problem with strptime and 2010 dates
Hi, I'm reading data from a text file and transforming it in R and my date
column seems to be getting corrupted. Can someone point out what's wrong?
This code worked fine until I added a new date in 2010.
thank you.
To load the data I run:
work_table = read.table(datafilename,header=TRUE) #read the
data file
attach(work_table)
2003 Jan 09
2
Warnings with no INDEX file in a package.
In previous versions of R (at least in 1.5.1, I think), my practice was not to
include an INDEX file in the package. R CMD check did not complain and an INDEX
was created for me when I use R CMD build.
At least, this is how I remember it. I thought that this was a good way to
behave since it ensured that my INDEX was automatically kept up to date by R,
without me having to worry about what
2017 Jan 17
1
strptime("1","%m") returns NA
Hi Frederik,
On Mon, 2017-01-16 at 18:20 -0800, frederik at ofb.net wrote:
> Hi R Devel,
>
> I wrote some code which depends on 'strptime' being able to parse an
> incomplete date, like this:
>
> >
> > base::strptime("2016","%Y")
> [1] "2016-01-14 PST"
>
> The above works - although it's odd that it gives the month
2001 Sep 26
1
Characters vectors, NA's and "" in merges
I often use merge with dataframes that contain character vectors which have
elements that are sometimes "NA" (meaning the string NA, not the same thing,
obviously, as NA in a numeric or factor vector). For example, the stock ticker
for Nabisco was "NA". Unfortunately (for me), it seems like merge insists on
inserting "NA" for missing values. My question: Is there some
2006 Apr 15
1
strptime failure R 2.2.1 (PR#8773)
Full_Name: Bill Hutchison
Version: 2.2.1
OS: Windows XP
Submission from: (NULL) (69.158.121.13)
example(strptime) produces the following error:
Error in strptime(x, "%d%b%Y") : 2 arguments passed to 'strptime' which requires
3
This error occurs wherever strptime is used. It does not occur in 2.2.0
2011 Feb 08
3
strptime "March 14 2010" and NA?
Converting date strings that range between Mar-14-2010 2:00 and
Mar-14-2010 2:59 (inclusive) to date objects (POSIX) returns a NA entity:
> strptime("3/14/2010 2:00",format="%m/%d/%Y %H:%M")
[1] "2010-03-14 02:00:00"
This looks fine, however other functions such as plot see a NA object
instead:
> is.na(strptime("3/14/2010
2011 Jun 17
1
issue with strptime
Hi everyone,
I have bunch of date and time observations in the format %Y-%m-%d %I %M %S
%p. I used strptime() to read this format. But the problem is some of the
times are in the format of %I %M %p, so for those times, strptime is giving
me NA values.
For example,
strptime(paste("2009-04-08","1:49:47 PM"),format="%Y-%m-%d %I:%M:%S %p")
[1] "2009-04-08
2017 Jan 11
2
bug with strptime, %OS, and "."
On Tue, Jan 10, 2017 at 08:13:21PM -0600, Dirk Eddelbuettel wrote:
>
> On 10 January 2017 at 17:48, frederik at ofb.net wrote:
> | Hi R Devel,
> |
> | I just ran into a corner case with 'strptime'. Recall that the "%OS"
> | conversion accepts fractional seconds:
> |
> | > strptime("17_35_14.01234.mp3","%H_%M_%OS.mp3")$sec
> |
2002 Apr 30
2
display of character NA's in a dataframe in 1.5.0
I understand that NA's in character vectors are displayed differently than NA's
in factor vectors.
> c("x", NA, "y")
[1] "x" NA "y"
> as.factor(c("x", NA, "y"))
[1] x <NA> y
Levels: x y
That seems sensible enough. But shouldn't I see the same behavior in a dataframe?
> test <- data.frame(a =
2012 Jul 10
1
Negative years with strptime?
Is there a way to make as.Date() and strptime() process strings with
negative years? It appears that Date objects can contain negative years and
you can convert them to strings, but you can't convert them back to Date
objects.
x <- as.Date(c("0001-01-24", "0500-01-24"))
as.character(x)
# "0001-01-24" "0500-02-02"
as.Date(as.character(x))
#
2002 Apr 08
1
Problem(?) in strptime()
I think the following examples illustrate the crux of the matter
(version and OS info are below).
The problem has to do with the transition from standard time to
daylight savings time. My timezone, US/Pacific, has two parts:
standard time (PST) 8 hours behind GMT and daylight savings time
(PDT) 7 hours behind GMT. The transition takes place this year on 7
April at 02:00, when 02:00 is
2006 Mar 07
3
Applying strptime() to a data set or array
I'm sure this is just the result of a basic misunderstanding of the
syntax of R, but I am stumped.
A <-
read.table(file="sumByThirtyMinute.csv",sep=",",col.names=c("date","pandl"))
A now consists of thousands of rows, but A$date is a string...
...
3183 2006-02-28 12:00:00 548.470
3184 2006-02-28 12:30:00 515.240
3185 2006-02-28 13:00:00